[kw-pm] Question regarding uploading file(s)
abez
abez at abez.ca
Wed Jan 9 08:07:35 PST 2008
From perldoc CGI:
To be safe, use the upload() function (new in version 2.47). When called
with the name of an upload field, upload() returns a filehandle, or
undef if the parameter is not a valid filehandle.
$fh = upload(’uploaded_file’);
while (<$fh>) {
print;
}
In an list context, upload() will return an array of filehandles.
This makes it possible to create forms that use the same name for
multiple upload fields.
It is returning a file handle, not a file name.
perldoc CGI http://perldoc.perl.org/CGI.html
abram
Robert Pike wrote:
> Hi all,
> Hopefully a quick question: has anyone written or
> familar with writing CGI script(s) (in Perl) to accept
> uploaded files? I've been trying to use the CGI module
> but it looks as though on the <CGI
> Handle>->import("filename") line is seems to stop at
> that point and not process any further. Any ehlp would
> be much appreciated. Here's a tim... I mean tidbit
> with a rough outline of what I'm trying.
>
> Rob
>
> our $query = new CGI;
> ...
> ...
> $imgKey = "uplImg1";
> $uploadFile = $query->upload($imgKey);
> #*** prints here do not get reached ***
> open UPLOADFILE, ">$defaultdir/uploads/$imgKey" or die
> "Can't open the destination file";
> binmode UPLOADFILE;
> while ( <$uploadFile> ) {
> print UPLOADFILE;
> }
> close UPLOADFILE;
>
>
> ____________________________________________________________________________________
> Looking for last minute shopping deals?
> Find them fast with Yahoo! Search. http://tools.search.yahoo.com/newsearch/category.php?category=shopping
> _______________________________________________
> kw-pm mailing list
> kw-pm at pm.org
> http://mail.pm.org/mailman/listinfo/kw-pm
>
>
> ** ACCEPT: CRM114 PASS osb unique microgroom Matcher **
> CLASSIFY succeeds; success probability: 1.0000 pR: 24.1521
> Best match to file #0 (/home/abez/crm/nonspam.css) prob: 1.0000 pR: 24.1521
> Total features in input file: 3236
> #0 (/home/abez/crm/nonspam.css): features: 663445, hits: 18615534, prob: 1.00e+00, pR: 24.15
> #1 (/home/abez/crm/spam.css): features: 8585329, hits: 11210305, prob: 7.05e-25, pR: -24.15
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 252 bytes
Desc: not available
Url : http://mail.pm.org/pipermail/kw-pm/attachments/20080109/e3ac6d1a/attachment.bin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 252 bytes
Desc: OpenPGP digital signature
Url : http://mail.pm.org/pipermail/kw-pm/attachments/20080109/e3ac6d1a/attachment-0001.bin
More information about the kw-pm
mailing list