1

I am using ajax for multiple image upload functionality. I also display the preview of image before uploading. Now when I select 4 images(image1, image2, image3 and image4) and show the preview of them.

Now if I remove one image from selected but its still exist in : files[0]

How can I clear particular image from files[0].

I am reading these images from temp via using below code:

var reader = new FileReader();
reader.onload = imageIsLoaded;
reader.readAsDataURL(this.files[0]);
console.log(this.files[0]);

I just want to unset one particular image ( image1) from multiple images which I have selected for uploads.

Any help would be appreciative.

Raghbendra Nayak
  • 1,606
  • 3
  • 22
  • 47

1 Answers1

0

You can perhaps splice the array of files, something like this.

Example

$(document).ready(function(){
     var arr = ["jQuery","JavaScript","HTML","Ajax","Css"];
     var itemtoRemove = "HTML";
     arr.splice($.inArray(itemtoRemove, arr),1);
});​

So for your code

this.files.splice($.inArray(this.files[0], this.files), 1);