我从用户那里获取文件描述后,在mulitple fileupload中从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或未定义 ???
public ActionResult Upload(HttpPostedFileBase fileData, string description)
{
var fileName = this.Server.MapPath("~/uploads/" + System.IO.Path.GetFileName(fileData.FileName));
fileData.SaveAs(fileName);
return View();
}
请帮忙.. 不知道错误在哪里!!
答案 0 :(得分:-1)
使用此控制器
public string Upload(HttpPostedFileBase fileData)
{
var fileName = this.Server.MapPath("~/uploads/" + System.IO.Path.GetFileName(fileData.FileName));
fileData.SaveAs(fileName);
return "ok";
}