I'm using blueimp plugin to upload files and everything is working fine.
However, ater the upload complete , I get this in the navigator console:
Uncaught TypeError: Cannot read property 'length' of undefined
n.extend.each @ jquery-2.1.4.min.js:2
up.find.fileupload.done @ imgdown.js:45
$.Widget._trigger @ jquery.ui.widget.js:527
$.widget._onDone @ jquery.fileupload.js:862
(anonymous function) @ jquery.ui.widget.js:127
(anonymous function) @ jquery.fileupload.js:908
j @ jquery-2.1.4.min.js:2k.fireWith @ jquery-2.1.4.min.js:2
x @ jquery-2.1.4.min.js:4k.cors.a.crossDomain.send.b @ jquery-2.1.4.min.js:4"
I want to know if there is a way to fix that.
here is the code:
imgdown.js
form.fileupload({
url: form.attr('action'),
dataType: 'html',
done: function (e, data) {
$.each(data.result.files, function (index, file) {
$('<p/>').text(file.name).appendTo('#icon');
});
},
progressall: function (e, data) {
showprog( form.find('div#progress') );
var progress = parseInt(data.loaded / data.total * 100, 10);
up.find('#progress .progress-bar').css( 'width', progress + '%' )
.text( progress + '%' );
}
}).prop('disabled', !$.support.fileInput)
.parent().addClass($.support.fileInput ? undefined : 'disabled');
data.result.files
is not an array or array-like object. It has no length
property. You need to figure out what it actually contains, and why it doesn't contain what you think it should. Start by looking at your browser's developer tools and finding out the value being sent to you in response to the AJAX request.