1

I am using uploadify tool to upload my files with out posting back and I am facing this problem "IO Error" or "HTTP Error" after publishing the site.

This is my code sample :

$('#UploadFile').uploadify({

    'uploader': '/Content/uploadify.swf',

    'script': '/Home/uploadify',

    'cancelImg': '/Content/cancel.png',

    'folder': '/Content/UploadedFiles',

    'auto': true

});

this is my action code

[HttpPost]
public string uploadify()
{
    string fileDirectory = Server.MapPath(@"\Content\UploadedFiles\");
    string signuterName = _fileStore.SaveUploadedFile(Request.Files[0], fileDirectory);
    Session["SignuterfilePath"] = @"/Content/UploadedFiles/" + signuterName;
    return signuterName;
}

http://www.uploadify.com/documentation/

thanks.

1
  • We need the code of your controller and action too. Commented Mar 10, 2011 at 9:36

1 Answer 1

1

You seem to have hardcoded urls which might break when deploying your site under a virtual directory. I would recommend you always using URL helpers when dealing with urls:

$('#UploadFile').uploadify({
    'uploader': '<%= Url.Content("~/Content/uploadify.swf") %>',
    'script': '<%= Url.Action("Uploadify", "Home") %>',
    'cancelImg': '<%= Url.Content("~/Content/cancel.png") %>',
    'folder': '<%= Url.Content("~/Content/UploadedFiles") %>',
    'auto': true

});

UPDATE:

Also your controller actions normally return ActionResults not strings:

[HttpPost]
public ActionResult Uploadify()
{
    // Notice the argument of the MapPath method:
    string fileDirectory = Server.MapPath(@"~/Content/UploadedFiles/");

    string signuterName = _fileStore.SaveUploadedFile(Request.Files[0], fileDirectory);

    // Warning: You don't have access to the Session in requests
    // performed by Flash plugins
    //Session["SignuterfilePath"] = @"/Content/UploadedFiles/" + signuterName;

    // Return an ActionResult
    return Content(signuterName, "text/plain");
}

You will also notice that I have removed the Session call from your controller action. The reason for this is the the Uploadify plugin uses Flash and Flash doesn't have access to cookies, so when the request is performed there won't be any Session associated with it.

Sign up to request clarification or add additional context in comments.

2 Comments

the problem is the request did not even reach the action method after modifying js function as u said.
Darin's rewrite had a capital U in uploadify; could that be it? Otherwise, the solution has just worked for me. (btw: the "IO Error" occurs if the target folder doesn't exist, and the HTTP one if it's created, but script points in the boonies; this despite onError having a 404 check).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.