0
如果我們要進行文件上載和表單屬性enctype="multipart/form-data"
,我正在獲取表單數據值NULL
%fdat
變量EmbPerl
。在EmbPerl中獲取表單數據值爲%fdat中的空值
這裏是EmbPerl代碼:
if((defined $fdat{file} && $fdat{file}) && $fdat{upload})
{
$filename = "/tmp/sample.txt";<br/>
open (FILE, "> $filename") || die("open failed: $!");
while (read($fdat{file}, $buffer, 32768)) {
print FILE $buffer || die("print test: $!");
close FILE || die("close test: $!");
}
和HTML代碼是:
<form name="form1" method="post" enctype="multipart/form-data" onsubmit="return validation();>
<table>
<tr> <td>Select EXCEL sheet</td>
<td><input type="file" name="file" value=""></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="upload" value="upload"></td>
</tr>
</table>
</form>
我使用EmbPerl/2.3.0,CGI/3.63,Perl的/ 5.10.1,阿帕奇/ 2.2.22和Linux操作系統。