Answer the question
In order to leave comments, you need to log in
Ajax file upload?
The page displays a select, with a list. Next to it is a file selection button (implemented using the jQuery File Upload lag).
I select a file, there is a process. Then I need to select another select and another file without waiting and send it for processing in the same way.
How to implement it?
Answer the question
In order to leave comments, you need to log in
Implement something like a stack (array) where you will put new files.
In parallel, organize a function that listens to some custom event like "file-upload-added".
In the function, implement a mechanism for selecting files from the stack and send files for download one by one in the background.
I mean something like this:
var files = [];
.bind("file-upload-added", function() {
var file;
if (files.length) {
file = files.pop();
} else {
return;
}
$.ajax({
...
...
...
success: function() {
.trigger('file-upload-added');
}
})
});
.bind("file-upload-selected", function(file) {
files.push(file);
.trigger('file-upload-added');
})
For example, like this:
<iframe name="upload-iframe" style="display: none;"></iframe>
<form id="upload-form" action="/upload" target="upload-iframe" method="post" enctype="multipart/form-data">
<input type="file" name="file" id="file-input"/>
<script>
$('#file-input').change(function(){
$('#upload-form').submit();
});
</script>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question