0

Source Code :

<form role="form" action="uploadrit.php" method="post" enctype="multipart/form-data">
        <label class="input" >Choose File Of CSV Format</label>
        <input class="input" type="file" name="file" id="file" class="form-control" required="required">        
        <button class="input" type="submit" name="AddFile" class="btn btn-primary">Submit</button>
</form>

I want to select all file from directory using file upload control and send one by one file to uploadrit.php.

Vasim Shaikh
  • 4,171
  • 1
  • 19
  • 45
  • 4
    Hi, welcome to Stack Overflow. Submit your code and someone will help you, just show your effort. :-) – Ema.jar Dec 25 '16 at 11:24
  • 1
    Possible duplicate of [How can I select and upload multiple files with HTML and PHP, using HTTP POST?](http://stackoverflow.com/questions/1175347/how-can-i-select-and-upload-multiple-files-with-html-and-php-using-http-post) – bansi Dec 25 '16 at 11:32
  • make question more clear based on code. – Vasim Shaikh Dec 27 '16 at 16:12

2 Answers2

0

You should add multiple attribute to your file tag:

<form role="form" action="uploadrit.php" method="post" enctype="multipart/form-data">
        <label class="input" >Choose File Of CSV Format</label>
        <input class="input" type="file" name="file" multiple id="file" class="form-control" required="required">        
        <button class="input" type="submit" name="AddFile" class="btn btn-primary">Submit</button>
</form>

If you need to handle the files via Javascript, you can use File API. Example documentation: http://developer.mozilla.org/en-US/docs/Using_files_from_web_applications

Emil Alkalay
  • 426
  • 4
  • 15
0

Instead sending the files one by one, use the multiple flag and send the files as an array. Here is an example:

<form action="file-upload.php" method="post" enctype="multipart/form-data"> <input type="file" name="files[]" multiple> <input type="submit" value="Upload"> </form>

Pay attention to input where I've used the multiple flag as well as have declared the name of the input as an array. In your PHP file, loop through $_FILES['files'] to get all selected files.

Rehmat
  • 3,732
  • 1
  • 16
  • 32