Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Getting a filehandle for uploaded file

by cdarke (Prior)
on Oct 20, 2009 at 13:01 UTC ( [id://802221]=note: print w/replies, xml ) Need Help??


in reply to Getting a filehandle for uploaded file

where $fh was simply the name of the uploaded file.

I don't think so. From the doc:
perldoc -f read read FILEHANDLE,SCALAR,LENGTH,OFFSET read FILEHANDLE,SCALAR,LENGTH Attempts to read LENGTH *characters* of data into variable SCALAR from the specified FILEHANDLE...
You must have got the filehandle from somewhere. Note that upload takes the name of the file, not the name of the parameter which holds the filename.

Update: Scratch last sentence. It is not true for $cpi->upload. See Bloodnok's post below.

Replies are listed 'Best First'.
Re^2: Getting a filehandle for uploaded file
by luker (Initiate) on Oct 20, 2009 at 13:48 UTC
    Thanks for the swift reply. I'm not sure I agree with your comment about CGI::upload though. According to man CGI:
    CREATING A FILE UPLOAD FIELD ... print filefield(-name=>'uploaded_file', ... When the form is processed, you can retrieve the entered filename by c +alling param(): $filename = param('uploaded_file');
    i.e. param is called with the name of the field.

    Then it says:

    The filename returned is also a file handle... # Copy a binary file to somewhere safe open (OUTFILE,">>/usr/local/web/users/feedback"); while ($bytesread=read($filename,$buffer,1024)) { print OUTFILE $buffer; }
    I have also tried the no strict trick mentioned there, but it didn't help. Have also checked it's not browser-dependent.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (7)
As of 2024-04-23 19:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found