Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^4: Downloading things from a database

by upallnight (Sexton)
on Jun 01, 2008 at 06:32 UTC ( #689524=note: print w/replies, xml ) Need Help??


in reply to Re^3: Downloading things from a database
in thread Downloading things from a database

Yes, this would take a lot of memory if you read in a large file to a string first.
To force download of a large file, just print the file as you read it in like this:

if(-e $file) { if(open(SESAME, "< $file")) { print "Content-Disposition: attachment; filename=$file\n"; print "Content-Type: application/octet-stream\n"; print "Content-Length: " . (-s $file) . "\n\n"; while(<SESAME>) { print $_; } close(SESAME); } else { print "Content-Type: text/html\n\nError: Could not read from f +ile\n"; } } else { print "Content-Type: text/html\n\nError: invalid filename\n"; }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://689524]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2022-05-23 23:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (82 votes). Check out past polls.

    Notices?