daily pastebin goal
48%
SHARE
TWEET

Untitled

a guest Jul 12th, 2018 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. function file_newname($path, $filename){
  4.     if ($pos = strrpos($filename, '.')) {
  5.            $name = substr($filename, 0, $pos);
  6.            $ext = substr($filename, $pos);
  7.     } else {
  8.            $name = $filename;
  9.     }
  10.  
  11.     $newpath = $path.'/'.$filename;
  12.     $newname = $filename;
  13.     $counter = 0;
  14.     while (file_exists($newpath)) {
  15.            $newname = $name .'_'. $counter . $ext;
  16.            $newpath = $path.'/'.$newname;
  17.            $counter++;
  18.      }
  19.  
  20.     return $newname;
  21. }
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