2013-03-14 68 views
0

我從scriptData傳遞文件描述文件上傳多張正從用戶的文件描述後..無法在Uploadify中傳遞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控制器我沒有得到它正在通過爲空或描述的值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(); 
    } 

請幫助.. 不知道哪裏出錯!

+0

是您的第一個文件的數據做它對你的行動?第一個沒有設置的文件的數據?另外,我在文檔中找不到scriptData,但是我發現formData http://www.uploadify.com/documentation/uploadify/formdata/ – Jasen 2013-03-14 23:02:22

回答

-1

使用該控制器

public string Upload(HttpPostedFileBase fileData) 
    { 
     var fileName = this.Server.MapPath("~/uploads/" + System.IO.Path.GetFileName(fileData.FileName)); 
     fileData.SaveAs(fileName); 
     return "ok"; 
    } 
+0

這段代碼如何幫助OP檢索描述? – 2013-04-18 01:55:55