Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Uploading multiple files

by inblosam (Monk)
on Apr 28, 2006 at 16:12 UTC ( [id://546314]=perlquestion: print w/replies, xml ) Need Help??

inblosam has asked for the wisdom of the Perl Monks concerning the following question:

I have a form that I want to upload photos with. I can make it work perfectly with one file, but I want them to be able to add multiple files and when I try that the files get saved but with 0 bytes. (FYI - I am using Mason)
<input type="file" name="file_1"> <input type="file" name="file_2"> <input type="file" name="file_3">
And then to process the submission of the files...
if ($fileList[0]) { my $uploadCnt = 3; my $fileCnt = 1; for (;$fileCnt<=$uploadCnt;$fileCnt++) { my $upfile = $ARGS{"file_$fileCnt"}; ### this passes the file to the mason component I created +to upload files my $fileRef = $m->comp("fileUploader.mas",upload_file=>$up +file); } }
Whereas with just one file, I just send the file_1 directly to my uploader, like so:
my $fileRef = $m->comp("fileUploader.mas",upload_file=>$file_1);
When I do a Data::Dumper (print Dumper(\$upfile)) it just has the file name in there. Is there a default folder on the server the files are being stored at temporarily that I can just prepend to that file and move it? I am not sure what is happening and what to do to fix it. Any suggestions?


Michael

Replies are listed 'Best First'.
Re: Uploading multiple files
by suaveant (Parson) on Apr 28, 2006 at 17:38 UTC
    I realize I am not answering your question here exactly, but this might make your user experience a little better. If you are uploading any number of files I would suggest creating a zip file or tar gzip, whatever, of all the files and uploading them as a single file, and coding your script to extract them.

    The main reason I suggest this is that if you want more than a small handful of files going through the html file selection method is a real pain. It's real easy to support on the script end, too. Man, I wish walmart would allow that for their one hour photo uploads.

                    - Ant
                    - Some of my best work - (1 2 3)

Re: Uploading multiple files
by TedPride (Priest) on Apr 28, 2006 at 16:42 UTC
    Dunno how I'd modify your code to make it work, but I've had success with Jeff Carnahan's File Uploader in the past. It only allows up to 4 files at once, but I'm sure that's easily modified by changing a few variables.
Re: Uploading multiple files
by TedPride (Priest) on Apr 28, 2006 at 20:13 UTC
    Now that's thinking outside of the box! ++

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (4)
As of 2024-04-25 15:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found