Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > CGI.pm - Upload multiple files using the same query param

Reply
Thread Tools

CGI.pm - Upload multiple files using the same query param

 
 
diegodelima.poa@gmail.com
Guest
Posts: n/a
 
      01-04-2007
I need to upload multiple files using inputs with the same name, like
an array of files.

I know CGI.pm understands pretty well any number of inputs of type text
with the same name, and i've been using it for a while. This time I
need the same behavior with uploading files.

Is this possible?

I know many will advice me to use file1, file2, fileN, but I have some
platform specific reasons that would meke it lots easier to me if using
the same param names where possible.

Thanks!

Diego de Lima

 
Reply With Quote
 
 
 
 
usenet@DavidFilmer.com
Guest
Posts: n/a
 
      01-04-2007
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> I need to upload multiple files using inputs with the same name, like
> an array of files.


No problem. For example:

for (1..5) {
print p( filefield(-name=>'upload',-size=>60) );
}

That prints out five upload fields with the same parameter name, and
the parameter will act like an ordinary array when you go to process
it:

foreach my $file( param('upload') ) {
# upload the file and do whatever.
}


--
The best way to get a good answer is to ask a good question.
David Filmer (http://DavidFilmer.com)

 
Reply With Quote
 
 
 
 
J. Gleixner
Guest
Posts: n/a
 
      01-04-2007
(E-Mail Removed) wrote:
> I need to upload multiple files using inputs with the same name, like
> an array of files.
>
> I know CGI.pm understands pretty well any number of inputs of type text
> with the same name, and i've been using it for a while. This time I
> need the same behavior with uploading files.
>
> Is this possible?
>
> I know many will advice me to use file1, file2, fileN, but I have some
> platform specific reasons that would meke it lots easier to me if using
> the same param names where possible.


How would the server know anything about the files on the client? The
server only knows what is sent to it, so you either upload multiple
files, using multiple input type="file" elements, or you tar/zip
them on the client and send one, then untar/unzip on the server.
Another choice is to use JavaScript to automate it, many are
available by searching the Internet.
 
Reply With Quote
 
Gunnar Hjalmarsson
Guest
Posts: n/a
 
      01-04-2007
(E-Mail Removed) wrote:
> I need to upload multiple files using inputs with the same name, like
> an array of files.
>
> I know CGI.pm understands pretty well any number of inputs of type text
> with the same name, and i've been using it for a while. This time I
> need the same behavior with uploading files.
>
> Is this possible?


Yes. One easy way to do it is to make use of the CPAN module
CGI::UploadEasy.

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
HTML::Template->param() : You gave me an odd number of parameters to param()! Dave Perl Misc 5 04-26-2011 02:44 AM
Overload by deriv class param; call w base class param ectoplasm C++ 12 07-28-2005 08:20 AM
Text files read multiple files into single file, and then recreate the multiple files googlinggoogler@hotmail.com Python 4 02-13-2005 05:44 PM
using param to access parameters with the same name homecurr Java 1 07-23-2004 01:13 AM
XSLT: How to replace param name with this param's value ? Geathaa XML 2 07-30-2003 06:48 AM



Advertisments