in reply to Re: Non-Duplicate File Names, Security, and Self Cleaning
in thread Non-Duplicate File Names, Security, and Self Cleaning
And here is the actual script. It's shorter and pretier, but I can't get it to force a download of the new file (oh, I should mention that on advice of fglock I went to Archive::Tar instead of Archive::Zip):<html> <body> <form action='../cgi-bin/maketar.cgi' method='post'> <input type=checkbox name="1.text">1<br> <input type=checkbox name="2.text">2<br> <input type=checkbox name="3.text">3<br> <input type=checkbox name="4.text">4<br> <input type=checkbox name="5.text">5<br> <input type=submit> </form> </body> </html>
CGI::Push isn't going to do it, I don't think. What happens with the code as is, using Indigo Perl's Apache bundle locally on my machine the script creates a .tar file, tries to display the contents, can't and the script runs again, creating an infinite (until I intervene) number of .tar files in the cgi-bin directory. On my webserver it makes one .tar file, then shuts down. RTFMing is proving quite educational, but I'm not seeing a way to open a download file box. I could do something like:#! /usr/bin/perl/bin/perl -wT use CGI; use strict; use File::Temp; use Archive::Tar; # Create CGI object and make array or params # The name will come from the HTML checkbox tags my $q = CGI->new(); my @selectedFiles = $q->param; # Create random $filename and .tar file with that name (my $fh, my $filename) = File::Temp::tempfile( "img_XXXX", SUFFIX=>'.t +ar' ); my $tar = Archive::Tar -> new ( $filename ); # Add the files to the .tar file and write it to disk $tar->add_files ( @selectedFiles ); $tar->write ( $filename, 0 ); ###### Here's the Trouble ###### # Send the .tar file to the browser print $q->redirect( $filename ); ################################ # Erase the .tar file from the server File::Temp::unlink0($fh, $filename) or die "Error unlinking $filename +safely";
but I'd like to avoid that if possible. Any way I could?print $q -> start_html, $q -> a ( "$filename", $filename ), $q -> end_html;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Non-Duplicate File Names, Security, and Self Cleaning
by chromatic (Archbishop) on Jun 12, 2003 at 07:07 UTC |