我需要使用多种文件输入类型上传多个文件。我知道只需一个输入类型就可以用CTRL +单击文件来完成。我使用perl作为我的后端部分。
<form action="dsadsa" method="post" enctype="multipart">
<tr>
<td>
<input type="file" id="file_upload" name="file_upload" multiple >
</td>
</tr>
<tr>
<td>
<input type="file" id="file_upload" name="file_upload" multiple>
</td>
</tr>
<tr>
<td>
<input type="file" id="file_upload" name="file_upload" multiple>
</td>
</tr>
<tr>
<td>
<input type="file" id="file_upload" name="file_upload" multiple>
</td>
</tr>
<tr>
<td>
<input type="file" id="file_upload" name="file_upload" multiple>
</td>
</tr>
<tr>
<input type="submit" />
</form>
那是我的HTML部分。
我正在使用ajaxForm插件上传文件。
var options = {
beforeSend: function () {
},
uploadProgress : function (event, position, total, percentComplete) {
},
success : function (data) {
},
error : function (response) {
},
};
$('#myForm').ajaxForm(options);
但它无法获取任何参数(file_upload)
万一你想看到我的perl方面:
if ($path eq 'dsadas') { #this is the path in the action part in the form
my @fhs = cgi->upload('file_upload'); # this is what im talking about, this should get all the files. I also tried using trim_param() instead of cgi->upload.
}
答案 0 :(得分:0)
基于此......
Can Perl's CGI.pm process Firefox's <input type="file", multiple=""> form fields?
将其修复在服务器端:
my @fhs = upload('file_upload');
use File::Type;
my $ft = File::Type->new();
my $i = 0;
my %mimes = { ( $i++ => $ft->checktype_contents(<$_>)) } @fhs;
或类似的......
这也有帮助 http://perldoc.perl.org/CGI.html#PROCESSING-A-FILE-UPLOAD-FIELD