A
A
alan312021-07-06 19:29:31
PHP
alan31, 2021-07-06 19:29:31

How to load files one by one into input file?

I have HTML code:

<form action="img.php" method='post' enctype="multipart/form-data">
  <input name='file' class='file_i' type="file">
  <input type="submit">
</form>


And how can I make it so that using input type='file' I can add several files in turn (first one then another, not like with multiple ) , and then when I click on input type='submit' all the files that I chose are sent to the folder files with php.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey delphinpro, 2021-07-06
@alan31

Change the field name to name="files[]"
To add the next file, make a button.
By clicking on this button, insert another type=file field with the same name into the form.
This is the basic functionality.
Then you can improve. Make the add file button visible only if the previous file is already selected, or add the next field immediately after selecting the previous one. Add the ability to delete selected files (also simply delete the corresponding field from the markup). Etc.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question