Hello.

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 :

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>');
but none of it works. It merely diplays the text on the screen, as described in the node above.

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).

Any ideas ?

MonkPaul.

Janitored by holli - fixed link


In reply to Download File using CGI by MonkPaul

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.