Why HTML5 input[type="file"] FileList object is readonly?

时间:2016-09-02 16:33:41

标签: javascript html5 file-upload

I wanted to create my own widget for uploading images to a server so apparently input[type="file"] was the way to go. However I also wanted some functionality:

  1. Display images' thumbnails
  2. Preview an image - displays image in larger scale
  3. Remove an image from the collection of images that is waiting to be uploaded

Everything was fine until I stumbled on point 3. from the list above. It turns out that the FileList object of the file input is readonly and you can't do any modifications on it. Thus if I wanted to remove an image I would have to choose all images except this one and overwrite the existing collection of images. So I wanted to know why they made it to be readonly? Are there some security reasons? Thanks.

It seems that you can't do everything in javascript after all, as I was starting to have such observations (lol).

0 个答案:

没有答案