- 论坛徽章:
- 0
|
之前要加上my $file = $q->param('uploadfile');
你用的$file是一个字符串,但是
- 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 seriously, 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 filehandle 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 = upload('uploaded_file');
- while (<$fh>) {
- print;
- }
复制代码
用upload来获得文件句柄好了
[ 本帖最后由 kamixp 于 2007-10-8 21:33 编辑 ] |
|