kostepanych
kostepanych

Reputation: 2619

How to remove files dynamically from upload form?

I want to create multiupload file component with possibility of removing added files dynamically with javascript (when user click on close button on file preview).

I tried to use <input type="file" name="files[]" multiple/> But as I found later there is no possibility of changing file input value dynamically :(

So what should I do for solving this problem? How to make possibility of removing files from form after it has been added by user?

Upvotes: 1

Views: 2309

Answers (1)

Viktor S.
Viktor S.

Reputation: 12815

First: take a look at this article. Here is how you can make multiple file upload (very simple, file is selected one by one)

Second: I do not think you can edit list of files in <input type="file" multiple /> with JS. According to this .files property is readonly (so you can get a list of files, but noting more). But at the same time, take a look at this. There you can find how to upload files with ajax. Once you can do that, you can show a list of selected files and allow user to remove some of them. And upload only files that are still in a list of selected files.

Upvotes: 1

Related Questions