0

嗨,我做了本教程中的所有操作,点击

但是当我尝试上传文件时,每次出现 POST not allowed 错误时,我都会检查 fiddler 并且 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();
}

});

});
4

1 回答 1

1

看起来教程是指一些旧版本的Uploadify,现在选项有点不同,你可以在这里找到最新列表。

我已经更新了您的代码(我已经评论了似乎不再存在的选项):

$("#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();
    }
});
于 2012-09-19T13:53:00.140 回答