title: php upload and rename images sequentially
body: <p>i have an issue with php image upload.</p>
  
  <p>I've made a form that allows user to upload an image.
  Tha image will be renamed, and till now everything's work fine.
  that i need is a function that rename my image like this:</p>
  
  <p>image1.(EXT)
  image2.(EXT)
  image3.(EXT)
  ...and so on</p>
  
  <p>so i need somthing to increase the number of the uploaded images sequentially, starting from 1.</p>
  
  <p>my code for now is this:</p>
  
  <pre><code>&lt;?php 
  $i = 0;
  
  
   function findexts ($filename) { 
   $filename = strtolower($filename) ; 
   $exts = split("[/\\.]", $filename) ; 
   $n = count($exts)-1; 
   $exts = $exts[$n]; 
   return $exts; 
   }
  
  
   $ext = findexts ($_FILES['ufile']['name']) ; 
   $target = "images/";
   $target = $target .'image'.$i++.'.'.$ext; 
  
    if(move_uploaded_file($_FILES['ufile']['tmp_name'], $target)) 
   {
   echo "The file has been uploaded as ".$i.$ext;
   } 
   else
   {
   echo "Sorry, there was a problem uploading your file.";
   } 
  
  ?&gt;
  </code></pre>