[kw-pm] Question regarding uploading file(s)

abez abez at abez.ca
Wed Jan 9 13:25:16 PST 2008


Read the CGI perldoc and look for multipart form, your submitting form
must be multipart (see the CGI perldoc) and have to send it correctly.
If the file was sent properly and you are capable of writing files with
that account it will work.

abram

Robert Pike wrote:
> Abez,
>    Hopefully a quick one. I tried doing what was
> suggested in the posts I got off the web and one thing
> fails to work. When I try uploading jpgs I can't open
> the copy that was uploaded (gives an error about
> improper format or something similar to that). In the
> examples off the web it says to upload(filename) and
> then read that file in and write it in binmode. Any
> ideas? Thanks again.
> 
> Rob
> --- abez <abez at abez.ca> wrote:
> 
>> 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 
>>>  
>>
>>
>>> _______________________________________________
>> kw-pm mailing list
>> kw-pm at pm.org
>> http://mail.pm.org/mailman/listinfo/kw-pm
> 
> 
> 
>       ____________________________________________________________________________________
> Be a better friend, newshound, and 
> know-it-all with Yahoo! Mobile.  Try it now.  http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ 
> 
>  
>  ** ACCEPT: CRM114 PASS osb unique microgroom Matcher ** 
> CLASSIFY succeeds; success probability: 1.0000  pR: 23.2914
> Best match to file #0 (/home/abez/crm/nonspam.css) prob: 1.0000  pR: 23.2914  
> Total features in input file: 5316
> #0 (/home/abez/crm/nonspam.css): features: 663445, hits: 31300778, prob: 1.00e+00, pR:  23.29 
> #1 (/home/abez/crm/spam.css): features: 8585329, hits: 16636278, prob: 5.11e-24, pR: -23.29 
>  


-------------- 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/0338192b/attachment.bin 


More information about the kw-pm mailing list