Hadi1989

Untitled

Jul 10th, 2018
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.54 KB | None | 0 0
  1. <?php
  2.     require_once 'conn.php';
  3.  
  4.     if(ISSET($_FILES['file']['name'][0])){ 
  5.         foreach($_FILES['file']['name'] as $key => $values){
  6.            
  7.             $file = explode(".", $values);
  8.             $ext = array("png", "gif", "jpg", "jpeg");
  9.            
  10.             if(in_array($file[1], $ext)){
  11.                 $file_name = $file[0].'.'.$file[1];
  12.                 $tmp_file = $_FILES['file']['tmp_name'][$key];
  13.                 $location = "upload/".$file_name;
  14.                
  15.                 if(move_uploaded_file($tmp_file, $location)){
  16.                     $conn->query("INSERT INTO `upload` VALUES('', '$file_name', '$location')");
  17.                 }
  18.             }
  19.         }
  20.     }
  21. ?>
Advertisement
Add Comment
Please, Sign In to add comment