beennn Posted May 29, 2015 Share Posted May 29, 2015 (edited) I'm trying to convert: http://techslides.com/demos/image-video/create.html to work with images on a server. Currently the demo above uses local files: if(filesarr.length>0){ //loop through them and process for(i=0; i<filesarr.length; i++) { var file = filesarr[i]; if(file.type.match(/image.*/)){ process(file); } else { document.getElementById('status').innerHTML = "This file does not seem to be a image."; } } } else { document.getElementById('status').innerHTML = "Please select some images."; } I'm trying to fetch them from a server, so I have replaced the above with: for(i=0; i < 2; i++) { var url = "http://localhost/uploads/" + i.toString() + ".png"; var file = new Blob(); var xhr = new XMLHttpRequest(); xhr.open('GET', url, true); xhr.responseType = 'blob'; xhr.onload = function(e) { if (this.status == 200) { file = new Blob([this.response], {type: 'image/png'}); process(file); } }; xhr.send(); } Could someone tell me what I am doing wrong? I am not getting any errors so I have no idea. EDIT: I feel very silly, there is nothing wrong with the above. I was still checking against the size of filesarr further down the script. Edited May 29, 2015 by beennn Link to comment Share on other sites More sharing options...
davej Posted May 30, 2015 Share Posted May 30, 2015 I see this described here... http://www.html5rocks.com/en/tutorials/file/xhr2/ ...but as the original article suggests, why not use a server tool such as... http://www.ffmpeg.org/ Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now