The thing i met with the ajaxForm plugin as following:
HTML:
<form id="uploadForm" method="post" enctype="multipart/form-data">
<input type="file" directory webkitdirectory name="fileToUpload" />
</form>
JavaScript:
$("input[name='fileToUpload']").change(function() {
var form = $('#uploadForm');
form.attr('action', uploadURL);
form.ajaxSubmit({
uploadProgress: function(event, position, total, percentComplete) {
var percentVal = percentComplete + '%';
console.log('percentVal', percentVal);
},
complete: function(xhr) {
console.log('completed');
},
success: function() {
console.log('success!!!!');
}
});
return false;
});
The problem is i cannot even set the uploadProgress
, once this callback was set, i got the 405 Method Not Allowed
error. But if i removed uploadProgress
from the ajaxSubmit
's options, only success
and complete
callback were left, the upload operation executed correctly.
That confused me a lot.