0

从用户获取文件描述后,我在多个文件上传中从 scriptData 传递文件描述。

<script type="text/javascript">
    var uploadQueue = new Array();
    $(window).load(
    function () {
        $("#fileuploader").fileUpload({
            'uploader': '/Scripts/uploader.swf',
            'cancelImg': '/Images/cancel.png',
            'buttonText': 'Upload Files',
            'script': 'Home/Upload',
            'folder': '/uploads',
            'scriptData': { 'description': $('#description_' + uploadQueue).val() },
            //'fileDesc': 'Image Files',
            //'fileExt': '*.jpg;*.jpeg;*.gif;*.png',
            'onSelect': function (event, queueID, fileObj) {
                uploadQueue.push(queueID);
            },
            'multi': true,
            'auto': false
        });

        $('#start').click(function () {
            $.each(uploadQueue, function (k, v) {
                alert($('#description_' + uploadQueue).val());
                //$('#fileuploader').fileUploadSettings('scriptData','description=test');
                $('#fileuploader').fileUploadStart(v);
            });
        });

    });



    </script>

<div id="fileuploader"></div>
<input type="button" id="start" value="start"/>

但不知何故,在MVC 控制器中,我没有得到它作为null 或 undefined传递的描述值???

  public ActionResult Upload(HttpPostedFileBase fileData, string description)
    {
        var fileName = this.Server.MapPath("~/uploads/" + System.IO.Path.GetFileName(fileData.FileName));
        fileData.SaveAs(fileName);

        return View();
    }

请帮助..不知道错误在哪里!

4

1 回答 1

-1

使用这个控制器

    public string Upload(HttpPostedFileBase fileData)
    {
        var fileName = this.Server.MapPath("~/uploads/" + System.IO.Path.GetFileName(fileData.FileName));
        fileData.SaveAs(fileName);
        return "ok";
    }
于 2013-04-18T01:35:37.967 回答