file rename while uploading
<p>I have a problem here im trying to upload a file </p>

<p>first time it is moving the filename from temp it its respective directory,</p>

<p>but again i try ot upload the aa different file with the same name it should rename the 
first time uploaded file </p>

<p>with date_somefilename.csv and give the filename to its original state</p>

<p>for example a file test.csv    ,im uploading it for first time it will upload to 
corresponding directory as </p>

<p>test.csv,when i upload a different csv file with same name test.csv</p>

<p>I need to get the </p>

<p>test.csv (latest uploaded file)</p>

<p>06222012130209_test.csv(First time uploaded file)</p>

<p>The code is below </p>

<pre><code>$place_file = "$path/$upload_to/$file_name";     



if (!file_exists('uploads/'.$upload_to.'/'.$file_name)) 
 {

move_uploaded_file($tmp, $place_file);  


}else{

 move_uploaded_file($tmp, $place_file); 
 $arr1 = explode('.csv',$file_name);
  $todays_date =  date("mdYHis");
   $new_filename = $todays_date.'_'.$arr1[0].'.csv';
  echo  $str_cmd = "mv " . 'uploads/'.$upload_to.'/'.$file_name . " uploads/$upload_to/$new_filename";
   system($str_cmd, $retval); 
} 
</code></pre>
