Advertisement
ssaidz

MultiUploads

Oct 25th, 2016
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.59 KB | None | 0 0
  1. <?php
  2. if(isset($_POST['upload'])){
  3.     foreach($_FILES['myfile']['name'] as $key => $val){
  4.         $name = $_FILES['myfile']['name'][$key];
  5.         $tmp  = $_FILES['myfile']['tmp_name'][$key];
  6.         if(trim($name)!=''){
  7.             $new_name = date('YmdHis').$name;
  8.             if(move_uploaded_file($tmp,'upload/'.$new_name)){
  9.                 echo 'Berhasil mengupload file '.$name.' ke Folder upload<br/>';
  10.             }
  11.         }
  12.     }
  13. }
  14. ?>
  15. <form method="post" enctype="multipart/form-data" action="">
  16. <?php
  17. for($i=1; $i<5; $i++){
  18. ?>
  19. <input type="file" name="myfile[]"/><br/>
  20. <?php } ?>
  21. <input type="submit" name="upload" value="Upload"/>
  22. </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement