Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Binary file upload truncation?

by BUU (Prior)
on Apr 13, 2003 at 01:08 UTC ( [id://250102]=perlquestion: print w/replies, xml ) Need Help??

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

I have apache set up on my home box for testing purposes. It works perfectly, i can serve html, datafiles, execute cgi scripts and so on and so forth. Now I have a perl script, whose main goal in life is to allow me to upload files. I am attempting to use CGI::Lite to accomplish this task. All I do is:
require CGI::Lite; my $c=new CGI::Lite; $c->parse_form_data;
Then i go and examine /tmp. The problem here is that non binary files, such as .txt and .cfg, upload perfectly. But as soon as i try to upload a binary file, such as a zip file, all I get is roughly the first 500 bytes or so. Anyone have any suggestions?

Replies are listed 'Best First'.
Re: Binary file upload truncation?
by jasonk (Parson) on Apr 13, 2003 at 02:12 UTC

    How are you creating the form you are uploading from? The default encoding type has a length limit that may not be long enough for the files you are uploading, make sure the form tag includes ENCTYPE="multipart/form-data".


    We're not surrounded, we're in a target-rich environment!
Re: Binary file upload truncation?
by screamingeagle (Curate) on Apr 13, 2003 at 08:50 UTC
    One small suggestion : one thing to check is to make sure you've called the binmode function before you being doing IO on the file data.
      Wow, good call. That was it, thanks.
Re: Binary file upload truncation?
by BUU (Prior) on Apr 13, 2003 at 01:14 UTC
    One further detail, I also receive this error message:
    Oh, Oh! I'm upset! Can't read what I want.
    Which appears to automatically come from line 998 in CGI::Lite;
Re: Binary file upload truncation?
by hossman (Prior) on Apr 13, 2003 at 19:56 UTC

    you might try playing with "set_buffer_size" ... if i understand the docs right, it needs to be at least as big as the smallest MIME part you expect to be submitted (ie: bigger then the size of the biggest file you expect to get uploaded)

    Try setting it to something obscenely big.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (4)
As of 2024-03-19 09:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found