This is a very simple HTML5 + PHP code to upload multiple files without using multiple FILE elements or Flash or JavaScript. Here in this code two things are most important:
1. First is name of file input element, you have to give it a name with square brakets for example txtFiles[] so that it will work as a array of files for PHP
2. Second is multiple attribute used in file input element which gives input file element the power of selecting multiple files.
Other things are as usual.
Warning: This script is just for uploading multiple files, it dose not take care of security issues, please check file type, extension, size etc. before uploading files because this is essential from security point of view.
Please feel free to post any questions or comments.
<? if(isset($_POST['submit'])){ for($i=0; $i<count($_FILES['txtFiles']['name']); $i++){ move_uploaded_file($_FILES['txtFiles']['tmp_name'][$i],$_FILES['txtFiles']['name'][$i]); } } ?> <html> <head> <title>How to upload multiple files in PHP</title> </head> <body> <form method="post" enctype="multipart/form-data"> <label>Files</label><input type="file" name="txtFiles[]" multiple/><input type="submit" name="submit" value="Upload"/> </form> </body> </html>