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

Re: Getting a filehandle for uploaded file

by bv (Friar)
on Oct 20, 2009 at 15:15 UTC ( [id://802250]=note: print w/replies, xml ) Need Help??


in reply to Getting a filehandle for uploaded file

Is the problem that you are trying to read from the filename, not the filehandle? From the CGI documentation:

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-like object, or undef if the parameter is not a valid filehandle.

Pulling a quote from Bloodnok's post below:

If there was a problem uploading the file -- for example, the file was bigger than the $CGI::POST_MAX setting -- $filename will be empty. We can test for this and report the problem to the user as follows:

So you could test for that, too.


print pack("A25",pack("V*",map{1919242272+$_}(34481450,-49737472,6228,0,-285028276,6979,-1380265972)))

Replies are listed 'Best First'.
Re^2: Getting a filehandle for uploaded file
by luker (Initiate) on Oct 20, 2009 at 15:51 UTC
    I've tried using the upload function. It returns undef, which, according to the man page, means the parameter is not a valid filehandle. But why not? I have a normal looking form field:
    <input type="file" name="file_image" ...
    I've done the test according to your second quote. There's definitely nothing coming back from:
    my $handle_in = $cgi->upload('file_image');
    But it's not a POST_MAX problem. That's set to -1, which means no limit. There's a function called cgi_error(), but that's not returning anything either.

      Did you specify the correct enctype for your form?

      <form enctype="multipart/form-data" method="POST" ...>
      
      Steve
      --

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2024-04-19 16:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found