CGI, header, and redirect

F

FLUX (a l'Ircam)

Hi Perl folk!

I have the following problem :
I want to upload a file (stored in a web server) to the browser, and then
delete the file in the server. This file contains the results of a sound
analysis/synthesis and is named XXX.zip with XXX the basename of the
initial sound file...

If I used: "redirect(-uri=>$UPLOAD_DIR/my_file.zip);"
it would be OK, but then I can't delete the file after it is
downloaded...

So I did the following :
<CODE>

print header(-type=>'application/zip');
open UPLOADFILE, "<$UPLOAD_DIR/$my_file.zip";
binmode UPLOADFILE;
while ( <UPLOADFILE> ){
print ;
}
close UPLOADFILE;
`rm -fr $UPLOAD_DIR/my_file.zip`;

</CODE>

But there is a big problem with that : when the user download the zip file
it is named like the cgi script : for exemple "get_result.cgi" instead of
"sound56.zip"

Is there a way to force a name? Maybe using an option in the header?
I read the CGI.pm perldoc and googled it, but I could'nt find anything of
value...

PS : sorry if you find this question stupid, but I'm quite new to Perl...

Flux
 
F

FLUX (a l'Ircam)

print header(-type=>'application/zip');
open UPLOADFILE, "<$UPLOAD_DIR/$my_file.zip";
binmode UPLOADFILE;
while ( <UPLOADFILE> ){
print ;
}
close UPLOADFILE;
`rm -fr $UPLOAD_DIR/my_file.zip`;

But there is a big problem with that : when the user download the zip file
it is named like the cgi script : for exemple "get_result.cgi" instead of
"sound56.zip"

Is there a way to force a name? Maybe using an option in the header?
I read the CGI.pm perldoc and googled it, but I could'nt find anything of
value...


Well, I just found it! Sorry for the nuisance. Here is the solution :
I had to use :
^^^^^^^^^^^^
print header(-type=>"application/octet-stream", \
-attachment=>"my_filezip");

instead of :
^^^^^^^^^^
print header(-type=>'application/zip');

See you!

Flux
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top