After loading page, I want to upload different images to server several times. Each time I choose image, ajax uploads it to server and then shows on screen. Problem is that it continues to upload the rest images after I choose them one after another, but shows on the screen only image N1 each time.
Script:
..............
On File input box change
var file = this.files[0];
then run ajax
$.ajax({
url: "/users/img_upload",
type: "POST",
data: new FormData(formdata[0]),
contentType: false,
cache: false,
processData:false,
success: function(data)
{
var reader = new FileReader();
reader.readAsDataURL(file);
reader.onload = imageIsLoaded;
imageIsLoaded function is here
function imageIsLoaded(e) {
$('#img').attr('src', e.target.result);
Now after I upload first image, it continues to show only first image even after I upload second, third and etc. I thought cache: false,
will prevent this but, unfortunately first image is cached :( Any way to solve this problem ?