Search code examples
jqueryasp.net-mvcuploadify

Why doesn't uploadify work for me in Firefox or Chrome?


I am trying to do a simple file upload from my ASP.NET MVC web app using uploadify. In IE8, it works fine. In Firefox and Chrome, it never seems to post to the controller action. Can someone help me find what I'm doing wrong?

Here's my html:

<input type="file" id="file_upload" name="FileData" />

I am including jquery 1.4.1 and the contents of the current version of uploadify 2.1.4, which itself includes swfobject 2.2.

Here's my script:

$(function () {

$("#file_upload").uploadify({
  'uploader':   '/Scripts/uploadify.swf',
  'script':     '/Uploads/UploadFile',
  'cancelImg':  '/Content/Images/cancel.png',
  'auto':       true,
  'multi':      false,
  'folder':     '/uploads',

  onComplete : function() {
    alert("complete");
  },

  onOpen : function() {
    alert("open");
  },

  onError : function (event, id, fileObj, errorObj) {
    alert("error: " + errorObj.info);
  }

});

});

And here's my controller action:

public string UploadFile(HttpPostedFileBase FileData)
{
    // do stuff with the file
}

In Chrome and Firefox, I get a "Error #2038" message, which seems pretty cryptic from what I can find on the google. What am I doing wrong?


Solution

  • Things to try:

    1. Your controller action should return ActionResult, not string
    2. Install Fiddler and see what happens under the covers (you will see the HTTP request/response frames and a possible error). Then compare the results between the different browsers to see if something changes.