Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- input.addEventListener("change", function (evt) {
- for (var i=0, j=this.files.length; i<j; i++) {
- file = this.files[i];
- formdata = new FormData();
- formdata.append("images[]", file);
- var xhr = new XMLHttpRequest();
- xhr.id = "progress_" + Math.floor((Math.random() * 100000));
- xhr.addEventListener("loadstart", function(e){
- $("#image-list").append('<progress min="0" max="100" value="0" id="'+this.id+'"></progress>');
- });
- xhr.upload.onprogress = function(e) {
- var done = e.position || e.loaded, total = e.totalSize || e.total;
- $("#" +this.id).attr('value', Math.floor((e.loaded / e.total) * 100) )
- };
- xhr.open('post', 'upload.php', true);
- xhr.send(formdata);
- }
- }, false);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement