I'm using valums ajax file-uploader
My nodejs server side looks like this:
fileStream = fs.createWriteStream(__dirname+'/../public/images/houses/'+rndname);
req.pipe(fileStream);
req.on('end', function() {
body = '{"success":"true", "name": "'+rndname+'"}';
res.writeHead(200,
{ 'Content-Type':'text/plain'
, 'Content-Length':body.length
});
res.end(body);
});
client side:
function createUploader(){
var uploader = new qq.FileUploader({
element: document.getElementById('homepic'),
action: '/server/upload',
allowedExtensions: ['jpg', 'png', 'gif'],
multiple:true,
onComplete: function(id, fileName, responseJSON){
$("#homepic").append("<img src='/images/houses/"+responseJSON.name+"' class='mediumpic' /> ");
}
});
}
window.onload = createUploader;
This all works for single file upload just great!
So imagine - i press on upload button, chose pic, it uploads really fast, shows up in screen. Now i want to upload another one. I choose pic, it uploads on server fast (i see it on server), i get back the response of new filename and success, i put the picture on screen with my append. But the picture does not show up. I try open in new tab just the pic and still nothing even though i see it on the server standing in the right dir. After like 3-5 min of waiting it just shows up, without even page refresh needed. Whats causing this behavior? Is it the piping and i need to call Mario to fix it or something else? :)