我使用jansy bootstrap替换asp.net FileUpload
。我已经借助此answer使用HttpPostedFile
成功检索了该文件:
HttpPostedFile image = Request.Files["myFile"];
现在,如何选择多个文件?使用asp.net FileUpload
,它只是添加AllowMultiple="True"
参数,然后在后面的代码中我简单地循环:
foreach (var image in FileUpload1.PostedFiles)
{...}
如何使用自定义控件执行此操作?这是我当前的html(这是第一个Image Upload Widget example):
<div class="fileinput fileinput-new" data-provides="fileinput">
<div class="fileinput-preview thumbnail" data-trigger="fileinput" style="width: 200px; height: 150px;"></div>
<div>
<span class="btn btn-default btn-file"><span class="fileinput-new">Select image</span><span class="fileinput-exists">Change</span>
<input type="file" id="myFile" name="myFile"></span>
<a href="#" class="btn btn-default fileinput-exists" data-dismiss="fileinput">Remove</a>
</div>
</div>
答案 0 :(得分:0)
您可以添加multiple
属性并将其值设置为multiple
以允许选择多个文件
<input type="file" id="myFile" name="myFile" multiple="multiple">