MonkPaul has asked for the wisdom of the Perl Monks concerning the following question:
I recently got information on some other nodes about creating and storing files using CGI.
Now i have the trouble of trying to get the browser to download them. I have a number of files ready for download in different directories on the server. The one i am trying to download here is called $updated - an updated text file.
I understand that the browser was designed not to download the files automatically, but i want it to do something at least that can allow for downloading from a server location.
My questions are: 1. I have tried to use the code from File Download from CGI Script but it doesnt work. I have the following :
but none of it works. It merely diplays the text on the screen, as described in the node above.print("<BR>DOWNLOAD ATTEMPT 0<BR>"); print ("Content-Type:application/x-download\n"); print ("Content-Disposition:attachment;filename=$updated\n\n"); print("<BR>DOWNLOAD ATTEMPT 1<BR>"); print $html->header(-type => 'application/octet-stream', -Content_Disposition => "attachment", -filename => $updated); print("<BR>DOWNLOAD ATTEMPT 3<BR>"); print $html->header(-type => 'application/octet-stream', -Content_Disposition => "attachment", -filename => $updated); print("<BR>DOWNLOAD ATTEMPT 4<BR>"); print ('<BR><a href="file.txt"></a><BR>'); ## added late print("<BR>DOWNLOAD ATTEMPT 5<BR>"); print ("Content-Disposition:attachment;filename=$updated<BR>"); print ("Content-type: application/octet-stream<BR><BR>"); print("<BR>DOWNLOAD ATTEMPT 6<BR>"); print('<a href="$updated?downloadid=1">download the txt file</a>');
2. If the files were downloaded where do they go if no directory is specified. With some of the code above i found that you could get the browser in theoru to display a save as box (not done working here).
MonkPaul.
Janitored by holli - fixed link
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Download File using CGI
by Joost (Canon) on Jun 01, 2005 at 14:48 UTC | |
by MonkPaul (Friar) on Jun 01, 2005 at 15:26 UTC | |
by Joost (Canon) on Jun 01, 2005 at 15:36 UTC | |
by Anonymous Monk on Jun 02, 2005 at 07:46 UTC | |
by MonkPaul (Friar) on Jun 03, 2005 at 09:06 UTC | |
|
Re: Download File using CGI
by wazoox (Prior) on Jun 01, 2005 at 14:45 UTC | |
by MonkPaul (Friar) on Jun 01, 2005 at 14:49 UTC | |
by Joost (Canon) on Jun 01, 2005 at 14:57 UTC | |
|
Re: Download File using CGI
by dragonchild (Archbishop) on Jun 01, 2005 at 14:43 UTC | |
|
Re: Download File using CGI
by tchatzi (Acolyte) on Jun 01, 2005 at 16:05 UTC |