The other users have stated that grabbing the filehandle via CGI.pm's param() method is the best way. Please use the upload() method rather than param(). It's meant to be that way nowadays :) param() works but has a couple of small annoyances. From perldoc CGI:
However, there are problems with the dual nature of the upload fields. If you "use strict", then Perl will complain when you try to use a string as a filehandle. You can get around this by placing the file reading code in a block containing the "no strict" pragma. More seri- ously, it is possible for the remote user to type garbage into the upload field, in which case what you get from param() is not a filehan- dle at all, but a string. 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 = $query->upload('uploaded_file'); while (<$fh>) { print; } In an array context, upload() will return an array of filehandles. This makes it possible to create forms that use the same name for mul- tiple upload fields. This is the recommended idiom.
If the above content is missing any vital points or you feel that any of the information is misleading, incorrect or irrelevant, please feel free to downvote the post. At the same time, please reply to this node or /msg me to inform me as to what is wrong with the post, so that I may update the node to the best of my ability.
In reply to Re: file upload
by Coruscate
in thread file upload
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |