In php, it is very easy to implement file upload. but if we want to upload multiple files at a time, how should we compile the code ?, If you need it, refer to the following section to explain the implementation methods.
To upload multiple files, add multiple input file fields to the form, and set the name attribute of these input files to the same name and use an array to name them, for example, filename []. Php code for file upload is the same as that for single file upload.
Here is an example of multifile upload:
HTML file example.html
Php file my_parser.php
<?phpif(isset($_FILES['file_array'])){ $name_array = $_FILES['file_array']['name']; $tmp_name_array = $_FILES['file_array']['tmp_name']; $type_array = $_FILES['file_array']['type']; $size_array = $_FILES['file_array']['size']; $error_array = $_FILES['file_array']['error']; for($i = 0; $i < count($tmp_name_array); $i++){ if(move_uploaded_file($tmp_name_array[$i], "test_uploads/".$name_array[$i])){ echo $name_array[$i]." upload is complete
"; } else { echo "move_uploaded_file function failed for ".$name_array[$i]."
"; } }}?>
Thank you for reading this article. I hope it will help you. thank you for your support for this site!