Guest User

Untitled

a guest
May 22nd, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.44 KB | None | 0 0
  1. <?php
  2. $ext = array('jpg', 'gif', 'mpg', 'mpeg', 'png');
  3. $destpath = 'galerije/';
  4.  
  5. $files = count($_FILES['file']['name']);
  6.  
  7. for($i = 0; $i < $files; $i++)
  8. {
  9.     if(in_array(pathinfo($_FILES['file']['name'][$i], PATHINFO_EXTENSION), $ext))
  10.     {
  11.         if(move_uploaded_file($_FILES['file']['tmp_name'][$i], $destpath . $_FILES['file']['name'][$i]))
  12.         {
  13.             // Success
  14.         }
  15.         else
  16.         {
  17.             // Failure
  18.         }
  19.     }
  20.     else
  21.     {
  22.         // Extension not allowed
  23.     }
  24. }
Add Comment
Please, Sign In to add comment