Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7056533
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:52:42+00:00 2026-05-28T03:52:42+00:00

I cant’ seem to work uploadify on ASP.NET MVC3, I searched a lot and

  • 0

I cant’ seem to work uploadify on ASP.NET MVC3, I searched a lot and the code below seem to work fine, but not for me. When I try and upload it via html uploading method it works, not so much with uploadify. All libraries are included correctly.

<!-- Not working, HTTP ERROR 500 -->
<input id="file" type="file" name="file" />
<script type="text/javascript">
    $(document).ready(function () {
        $('#file_upload').uploadify({
            // I tried to remove "/" at the start, does not help
            'uploader': '/Scripts/u/uploadify.swf',
            'script': '/home/upload',
            'cancelImg': '/Scripts/u/cancel.png',
            'folder': '/upload',
            'auto': true,
            'onError': function (event, ID, fileObj, errorObj) {
                alert(errorObj.type + ' Error: ' + errorObj.info);
            }
        });
    });
</script>

<!-- Working fine -->
<form action="home/upload" method="post" enctype="multipart/form-data">
  <label for="file">Filename:</label>
  <input type="file" name="file" id="file" />
  <input type="submit" />
</form>

Home Controller Action

[HttpPost]
public ActionResult Upload(HttpPostedFileBase file)
{
    var fileName = Path.GetFileName(file.FileName); // Object reference not set to an instance of an object. I get this if I try to upload via uploadify
    file.SaveAs(Server.MapPath("~/upload/") + fileName);
    return Content(fileName);
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T03:52:43+00:00Added an answer on May 28, 2026 at 3:52 am

    Didn’t you debug your code? Didn’t you notice that the file action argument is always null when the Upload action is hit? Your action argument is called file, so you need to specify that using the fileDataName option:

    'fileDataName' : 'file',
    

    By default uploadify uses Filedata, so if you don’t want to specify this name you could also adapt your action argument name to match this:

    [HttpPost]
    public ActionResult Upload(HttpPostedFileBase fileData)
    {
        var fileName = Path.GetFileName(fileData.FileName);
        fileData.SaveAs(Path.Combine(Server.MapPath("~/upload/"), fileName));
        return Content(fileName);
    }
    

    Also make sure that the ~/upload folder exists on your server. It doesn’t when you create a new ASP.NET MVC application.

    Another problem that I would like to point out with your code is that you have hardcoded absolutely all urls in your javascript. That’s very bad and chances are that your application won’t work when you deploy it in a virtual directory, say for example IIS.

    In ASP.NET MVC you should always use url helpers when dealing with urls, just like that:

    <script src="@Url.Content("~/Scripts/u/jquery.uploadify.v2.1.4.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/u/swfobject.js")" type="text/javascript"></script>
    
    <input id="file_upload" type="file" name="file" />
    
    <script type="text/javascript">
        $(document).ready(function () {
            $('#file_upload').uploadify({
                'uploader': '@Url.Content("~/Scripts/u/uploadify.swf")',
                'script': '@Url.Action("upload", "home")',
                'cancelImg': '@Url.Content("~/Scripts/u/cancel.png")',
                'folder': '@Url.Content("~/upload")',
                'auto': true,
                'onError': function (event, ID, fileObj, errorObj) {
                    alert(errorObj.type + ' Error: ' + errorObj.info);
                }
            });
        });
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I cant seem to get Uploadify (2.1.4) to work, In Google Chrome Inspector the
Eclipse CANT SIGN MY APP! But old version works fine.It just shows warnings below,
Cant please someone tell me why the code below crashes when executing, (compilation goes
I cant seem to get my session to time out. see below very simple
I cant seem to figure out why the style property is not getting updated.
Cant seem to find my problem, but what I am trying to do is
Cant seem to find the answer to this, I'm sure it's simple, but just
Cant find a way for S3 to work with spree. There seem to exist
I cant post the code (proprietary issues) but does anyone know what types of
I cant seem to work out how to add program arguments to the launch

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.