2012-09-19 61 views
0

嗨,我做的一切都是想在這個教程中clickUploadify MVC2 HTTP POST不alowed

但是當我嘗試上傳的文件,每次我得到了POST不允許的錯誤,我在拉琴檢查和GET例如作品:

GET /Scripts/uploadify/uploadify.swf?preventswfcaching=1348057301853 HTTP/1.1 

但我後的控制器方法不

POST /Scripts/uploadify/uploadify.swf HTTP/1.1 

頭的樣子:

[HttpPost] 
public string UploadFiles(HttpPostedFileBase FileData, FormCollection forms) 
{ 

和jQuery執行這樣的:

$(document).ready(function() { 

// Multiple files - single input 
var auth = "<% = Request.Cookies[FormsAuthentication.FormsCookieName]==null ? string.Empty : Request.Cookies[FormsAuthentication.FormsCookieName].Value %>"; 
var ASPSESSID = "dfgdf"; 
var entryID = "<%= ViewData["EntryID"] %>"; 

$("#file_upload").uploadify({ 
'uploader': '<%= Url.Content("~/Scripts/uploadify/uploadify.swf") %>', 
'script': '<%= Url.Action("uploadFiles","Home") %>', 
'scriptData': { ASPSESSID: ASPSESSID, AUTHID: auth, entryID: entryID }, 
'fileDataName': 'FileData', 
'buttonText': 'Select files', 
'multi': true, 
'width': 250, 
'sizeLimit': 200000000, 
'simUploadLimit': 1, 
'cancelImg': '<%= Url.Content("~/Scripts/uploadify/uploadify-cancel.png") %>', 
'folder': '/Content', 
'auto': false, 
'removeCompleted' : false, 
'onAllComplete' : function(event,data) { 
alert(data.filesUploaded + ' files uploaded successfully!'); 

}, 
'onSelectOnce' : function(event,data) { 
$("#uploadLink").show(); 
} 

}); 

}); 
+0

這將是有益的,如果你會分享一些你的代碼。通過查看教程,您應該首先在uploadFiles方法上添加[HttpPost]屬性。 – tpeczek

+0

@tpeczek編輯 – kosnkov

回答

1

它看起來像教程是指的一些舊版本Uploadify的,現在的選項是有點不同,你可以找到多達最新列表here

我已經更新了你的代碼(我評論過這似乎不存在了選項):

$("#file_upload").uploadify({ 
    'swf': '<%= Url.Content("~/Scripts/uploadify/uploadify.swf") %>', 
    'uploader': '<%= Url.Action("uploadFiles","Home") %>', 
    'formData': { ASPSESSID: ASPSESSID, AUTHID: auth, entryID: entryID }, 
    'fileObjName': 'FileData', 
    'buttonText': 'Select files', 
    'multi': true, 
    'width': 250, 
    'fileSizeLimit': 200000000, 
    //'simUploadLimit': 1, 
    //'cancelImg': '<%= Url.Content("~/Scripts/uploadify/uploadify-cancel.png") %>', 
    //'folder': '/Content', 
    'auto': false, 
    'removeCompleted': false, 
    'onQueueComplete': function(event,data) { 
     alert(data.filesUploaded + ' files uploaded successfully!'); 
    }, 
    'onSelect' : function(event,data) { 
     $("#uploadLink").show(); 
    } 
}); 
+0

哦,男人,謝謝,真的。 – kosnkov