Question

I am using Uploadify and something which was previously working now isn't and I'm not sure why. I get an HTTP error returned whenever I click upload. Watching the net tab in Firefox, it doesn't look like it's even sending anything to the server again.

I've tried putting in the error function to help debug but the status attribute is undefined..

$("#fileInput").uploadify({
                'uploader': '/scripts/upload/uploadify.swf',
                'script': '/Member/UploadImages/PerformUpload',
                'cancelImg': '/scripts/upload/cancel.png',    
                'multi': true,
                'simUploadLimit': 1,
                'fileDesc': "Images",
                'fileExt': "*.jpg;*. jpeg;*.bmp;*.png",
                'sizeLimit': 3000000,
                'onAllComplete':showFinishedLink,
                'onError': function (event, queueID ,fileObj, errorObj) {
                    var msg;
                    if (errorObj.status == 404) {
                       alert('Could not find upload script. Use a path relative to: '+'<?= getcwd() ?>');
                       msg = 'Could not find upload script.';
                    } else if (errorObj.type === "HTTP")
                       msg = errorObj.type+": "+errorObj.status;
                    else if (errorObj.type ==="File Size")
                       msg = fileObj.name+'<br>'+errorObj.type+' Limit: '+Math.round(errorObj.sizeLimit/1024)+'KB';
                    else
                       msg = errorObj.type+": "+errorObj.text;
                    alert(msg);
                    $("#fileUpload" + queueID).fadeOut(250, function() { $("#fileUpload" + queueID).remove()});
                    return false;
                    },
            });

Any ideas?

Was it helpful?

Solution

OK, figured out that the error debugging I was using was old and that I can say errorObj.info to get out the more detailed info on why it's not working.

Did this and turns out it's a 404 which means the script I'm attempting to POST to isn't being picked up even though it does exist. Sounds like a routing issue...

Case closed!

Just to add more info on this - the 404 was as a result of an old default Login url in the web.config file.

Once I fixed this, the 404 then became a 302 (looking at the IIS logs) as the site was redirecting me to the login page.

My upload script is in an authenticated area of the site and so I needed to use something which is described in this site

Using flash with aspnet mvc

OTHER TIPS

I was receiving a 302 error occurring only in Firefox/Chrome: IE8 worked fine. The problem turned out to be that Netscape was now sending auth cookies with it's file postback. I allowed the .ashx file which handled the upload a anonymous authorization in the web config, and had no further problems.

<location path="UploadifyUploadHandler.ashx">
  <system.web>
    <authorization>
      <allow users="?"/>
    </authorization>
  </system.web>
</location>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top