Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Nothing in form-data
  • I used Uploadify in an ASP.NET MVC application I'm working on, and at the start it works great. I have a series of handlers that perform extensive processing on the files, and this works exactly as I want it to already. There are two things I need to do in addition to the file processing, which are enabling multiple-file handling for a single control and showing a progress bar. Uploadify does both of these for me, and I really like it. I was very pleased to find out that replacing the argument for a server script with an MVC Controller worked without any problems.

    Here's the problem I ran into - I can't specify a folder to save the files to in the uploadify options. This must be taken care of in the Controller code. After removing the option to specify the upload folder, the program still runs without any error, but the form data that you'd be able to retrieve and process after clicking the submit button isn't available, so the files are not uploaded. Is there a way to feed the files being uploaded into the form data so I can still use the uploadify component? Barring that, how can I access the list of files being uploaded in the server code?
  • I was incorrect in my post. The information is in the form data. There are 2 upload controls for the upload component I've created on the current project, and so I check the control that the file came from to route it to the correct handler. This is obtained in the ASP.NET C# code by referencing the Request.Files.Keys collection. Each key in the Keys collection is the name of the control that uploaded the file. I didn't realize that the 'fileDataName' parameter of the uploadify function replaced this value. I changed that to the name of the control, and all was well in that regard.

    It might well be a result of showing a progress bar for each upload individually (I love that feature, by the way), but instead of submitting the form and sending the files to the form action as a collection, they're sent individually, one at a time. While debugging, I've seen that the code to upload is called separately for each file. The issue this causes with me is that since the form submission is not triggered as if from a submit button, I don't have access to the form variables. I'm keeping a primary key id in a hidden field on the form to identify which project item the uploaded files are associated with. The files are still getting picked up in the Request.Files collection, so I can process them, but I still need that id data. I'm working in a MVC application, so I don't have a Session variable I could write to. Any suggestions?
  • OK, a very savvy coworker queued me into the answer, so I thought I'd share it with anyone who runs into similar problems. I placed a script within the uploadify function call to add as an additional parameter the id I needed. It looked like this:

    $('#UploadComponent').uploadify({
    'uploader': '../../Content/uploadify.swf',
    'script': '/Assets/Upload/<%= Model.Asset.ID %>',
    'cancelImg': '../../Content/cancel.png',
    'fileDataName': UploadComponent',
    'multi': 'true'
    });

    In this MVC application, the Controller grabs the initial call, prepares the data for processing and sends it to a service class. So, my upload method looks a little like this:

    public ActionResult Upload(int id)
    {
    // Upload processing code here...
    }

    And that solved my problem. I no longer need to reference form variables, so I side-stepped the issue.