【发布时间】:2016-11-30 01:42:14
【问题描述】:
这是我的 HTML:
<input id="openbox_actual" class="btn btn-lg btn-warning" type="file" name="videoFile" style="display: none;" />
<input id="openbox_actual2" class="btn btn-lg btn-warning" type="file" accept="image/*" name="screenShots" multiple="multiple" style="display: none;" />
如上所示,一个文件输入采用视频文件,另一个采用多个图像文件。
这是控制器:
HttpPostedFileBase file = Request.Files["videoFile"];
HttpPostedFileBase screens = Request.Files["screenShots"];
从上面的代码,我可以访问/上传“文件”就好了。
但是,我不知道如何仅访问“屏幕”内的所有文件。
我见过很多例子,其中人们遍历“HttpPostedFileCollection”,但它包含所有文件,在每个文件输入中。我只想要“screenShots”多文件输入中的所有文件。
如果有人知道如何将文件数“限制”为 8 个,则加分。(例如,“screenShots”文件输入仅允许您总共上传 8 个文件。
谢谢, 你们太棒了!
【问题讨论】: