0

I am trying to achieve an iframe transport file upload, using the blueimp file upload plugin as follows:

$(jQueryUploadInput).fileupload();
$(jQueryUploadInput).fileupload('send', {
        forceIframeTransport: true,
        fileUpload: profilePicInput,
        url: $.acme.resource.links.editProfilePictureUrl
    })
    .error(function(jqXHR, textStatus, errorThrown) {
        debugger;
    })
    .success(function(result, textStatus, jqXHR) {
        debugger;
    });

When I debug the view that needs the file upload, the debugger call inside my error function is hit, but all three parameters are undefined, as if the error function was invoked for no reason. profilePicInput is a valid file input with one selected file. The action pointed to by $.acme.resource.links.editProfilePictureUrl is a valid action url, but a breakpoint in my controller never even gets hit. I also have no idea how to proceed.

I know the API doc says:

The fileInput property must be a jQuery collection with an input of type file with a valid files selection.

so I have tried both ways of setting the fileUpload option, with the same result.

fileUpload: profilePicInput
fileUpload: $(profilePicInput)

Just BTW, this code is being called inside a view model script, not directly in the view itself, if that might mean or affect anyhting. I don't see how, because the viewmodel script is loaded into the view anyway.

ProfK
  • 49,207
  • 121
  • 399
  • 775

1 Answers1

1

This is a common problem:

The last link advises the following:

processalways: function(e,data){
  if (data.files.error) alert(data.files[0].error);
}

You can also access any of the other Processing Callback Options. See the API.

Any processing failure for an individual file can, for example, also be checked with the processfail callback

function (e, data) {
    console.log('Processing ' + data.files[data.index].name + ' failed.');
}

I hope that answers your question. If I didn't understand your question correctly, please let me know.

Community
  • 1
  • 1
Jean-Paul
  • 19,910
  • 9
  • 62
  • 88
  • You do seem to have understood my question, but I don't understand why, if there is an error with an individual file should `processfail` yield any more error information than `error`? I suppose that answer lies at the end of another long night on this problem. – ProfK Dec 14 '14 at 17:05
  • @ProfK: But have you tried it? I thought that maybe it's due to the JSON format of the error message.. – Jean-Paul Dec 14 '14 at 17:26