First, when uploading multiple files with a single POST, you must have a separate file param for each file:
<input type="file" name="file1">
Second, you get the remote filename with param. Then change this into the local filename.
my $filename = $cgi->param('file1');
Third, you get the filehande with upload:
my $fh = $cgi->upload('file1');
Fourth, get the uploaded Content-Type (has absolutely ntohing to do with the page's Content-Type) with uploadInfo
my $content_type = $cgi->uploadInfo($filename)->{'Content-Type'};
I would suggest writing a function that handles a single file upload. And then call it multiple times for each file param in the form.
upload_file('file1');
upload_fiel('file2');
sub upload_file {
my ($param_name) = @_;
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.