Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Using Perl to Output Multiple Files for Download via a Browser

by Loops303 (Novice)
on Mar 06, 2013 at 16:33 UTC ( #1022031=perlquestion: print w/ replies, xml ) Need Help??
Loops303 has asked for the wisdom of the Perl Monks concerning the following question:

I am building a web form for a user to upload a csv file, check off what outputs they want (e.g., Report 1, Invoice, etc.) and then the script grabs the upload form and is supposed to spit out the various things they checked off as individual CSV files.

My problem is I can output to 1 single CSV, not multiple ones.

I've tried

print "Content-Type: multipart/mixed\n"; print "Content-disposition: attachment;filename=test.csv\n\n";

Which works to output the fist file.

For the next file, I've tried to start with the same above (with filename=test2.csv) or just the Content Disposition with a new filename.

The goal is to output test.csv and test2.csv.

What happens instead is it prints the content intended for test2 into test.csv.

Any advice on how to proceed will be much appreciated!

Thank you!

Comment on Using Perl to Output Multiple Files for Download via a Browser
Download Code
Re: Using Perl to Output Multiple Files for Download via a Browser
by daxim (Chaplain) on Mar 06, 2013 at 16:41 UTC
    Solution 1: Stream the CSV outputs into an archive (Archive::Zip), then create a response with the archive.

    Solution 2: Write the CSV outputs into separate temporary files, then create a response with a HTML document linking to the files.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1022031]
Approved by tmharish
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (5)
As of 2014-07-31 04:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (244 votes), past polls