【发布时间】:2013-08-10 20:40:57
【问题描述】:
尝试使用 Plack 处理多个文件上传。
我的表格:
<form id="file_upload" action="savefile" method="POST" enctype="multipart/form-data">
<input type="file" name="file[]" multiple>
<button>upload</button>
</form>
选择了两个文件,名为:x1 和 x2。 Data::Dumper 的结果:
my $u = $req->uploads;
是
$VAR1 = bless( {
'file[]' => bless( {
'headers' => bless( {
'content-disposition' => 'form-data; name="file[]"; filename="x2"',
'content-type' => 'application/octet-stream',
'::std_case' => {
'content-disposition' => 'Content-Disposition'
}
}, 'HTTP::Headers' ),
'filename' => 'x2',
'tempname' => '/var/folders/7l/nhyscwy14bjb_sxr_t2gynpm0000gn/T/7vt04wIrne',
'size' => 146
}, 'Plack::Request::Upload' )
}, 'Hash::MultiValue' );
因此,它只包含第二个文件x2,但当检查文件夹/var/folders/7l/nhyscwy14bjb_sxr_t2gynpm0000gn/T/ 时,它包含两个文件已上传。
问题是我如何才能将两个文件添加到脚本中,而不是最后一个?
【问题讨论】: