SHARE
TWEET

Untitled

a guest Nov 9th, 2019 85 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  <?php
  2.     $file = $_FILES['file']['name'];
  3.     $a = pathinfo($file);
  4.     $basename = $a['basename'];
  5.     $filename = $a['filename'];
  6.     $extension = $a['extension'];
  7.     $path = $_SERVER['DOCUMENT_ROOT'].'/up/images/'; # set upload directory
  8.    $dest = $path.$basename;
  9.     if(file_exists($dest))
  10.     {
  11.         $b = count(glob($path.$filename.'*.'.$extension))+1; # all matches + 1
  12.        for($i = 1; $i < $b; $i++)
  13.         {
  14.             if(!file_exists($path.$filename.$i.'.'.$extension))
  15.             {
  16.                 move_uploaded_file($_FILES['file']['tmp_name'],$path.$filename.$i.'.'.$extension);
  17.             }
  18.         }
  19.     }
  20.     else
  21.     {
  22.         move_uploaded_file($_FILES['file']['tmp_name'],$dest);
  23.     }
  24.     ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top