我正在uploadify为我的 MVC3 项目使用文件上传插件。
我正在尝试使用上传文件到控制器。
如何同时使用多文件上传和单文件上传?
我知道IEnumerable<HttpPostedFileBase> files用于多个文件和HttpPostedFileBase files单个文件上传。如何结合这些。
在我的项目中,用户可以选择多个文件或只选择一个文件将其上传到控制器。
所以,如果我IEnumerable<HttpPostedFileBase> files在我的控制器操作中使用,我无法获取单个文件(文件为空),如果我使用HttpPostedFileBase files它不显示任何内容,文件在这里始终为空。
如何使用单个文件上传,我可以上传多个文件,但不能上传单个文件。
如何得到这份工作?
这是我的代码:
HTML
    <body>
    @using (Html.BeginForm("Index", "Home", FormMethod.Post, new { enctype = "multipart/form-data" }))
            {
              <div id="fileupload" style="display:none">
                <div style="clear: none;">
                    File to Upload:
                    <input type="file" name="file_upload" id="file_upload" style="padding-left: 50px;"/><hr />
                </div>
                <p style="text-align: right;">
                    <input type="submit" id="selectimage" value="Ok" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only"/>
                    <input type="submit" id="cancelimage" value="Cancel" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" onclick="cancelupload();" />
                </p>
            </div>
            <input type="button" id="btnImg" />
            <div id="filecontent">
              Added Images:
             </div>
            }
    </body>
    <script>
$(function(){
    $('#file_upload').uploadify({
            'checkExisting': 'Content/uploadify/check-exists.php',
            'swf': '/Content/uploadify/uploadify.swf',
            'uploader': '/Home/Index',
            'auto': false,
            'buttonText': 'Browse',
            'fileTypeExts': '*.jpg;*.jpeg;*.png;*.gif;*.zip',
            'removeCompleted': false,
            'onSelect': function (file) {
                $("#selectimage").click(function () {
                    $("#file_upload-queue").appendTo("#filecontent");
                });
            }
        });
});
</script>
控制器动作
public ActionResult Index(IEnumerable<HttpPostedFileBase> fileData)
        {
            foreach (var file in fileData)
                {
                    if (file.ContentLength > 0)
                    {
                        string currpath = Server.MapPath("~/Images/");
                        currpath = Path.Combine(Server.MapPath("~/Images/Admin"), file.FileName);
                        file.SaveAs(currpath);
                    }
                }
            return View();
        }
我应该在控制器操作中进行哪些更改以使单文件上传和多文件上传正常工作?
更新
既不工作IEnumerable<HttpPostedFileBase> fileData也不HttpPostedFileBase fileData工作