kosnkov
kosnkov

Reputation: 5941

Uploadify mvc2 HTTP POST not alowed

Hi i did everything like in this tutorial click

but when i try to upload the files, each time i got POST not allowed error, i checked in fiddler and GET works for example:

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

but Post not

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

header of my controller method looks like :

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

and jquery implementation like :

$(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();
}

});

});

Upvotes: 0

Views: 460

Answers (1)

tpeczek
tpeczek

Reputation: 24125

It looks like the tutorial is refering to some older version of Uploadify, now the options are a little bit different, you can find up-to-date list here.

I have updated your code (I have commented options which doesn't seem to exist anymore):

$("#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();
    }
});

Upvotes: 1

Related Questions