Auto rename of the same filename in uploading file PHP code
<p>multiple_upload.php</p>

<p>This code below is the multiple_upload.php it has 2 buttons for upload and a submit button.
actual picture of it:</p>

<pre><code>&lt;table width="500" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC"&gt;
&lt;tr&gt;
&lt;form action="multiple_upload_ac.php" method="post" enctype="multipart/form-data" name="form1" id="form1"&gt;
&lt;td&gt;
&lt;table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF"&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;multiple Files Upload &lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Select file 
&lt;input name="ufile[]" type="file" id="ufile[]" size="50" /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Select file
&lt;input name="ufile[]" type="file" id="ufile[]" size="50" /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td align="center"&gt;&lt;input type="submit" name="Submit" value="Upload" /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/td&gt;
&lt;/form&gt;
&lt;/tr&gt;
&lt;/table&gt;
</code></pre>

<p><img src="http://i.stack.imgur.com/30FRf.jpg" alt="enter image description here"></p>

<p>multiple_upload_ac.php</p>

<p>this code will process the file that you put in this line of code <code>&lt;input name="ufile[]" type="file" id="ufile[]" size="50" /&gt;</code> it will save inside my upload folder.</p>

<pre><code>&lt;?php

//set where you want to store files
//in this example we keep file in folder upload 
//$HTTP_POST_FILES['ufile']['name']; = upload file name
//for example upload file name cartoon.gif . $path will be upload/cartoon.gif

$path1= "upload/".$HTTP_POST_FILES['ufile']['name'][0];
$path2= "upload/".$HTTP_POST_FILES['ufile']['name'][1];


//copy file to where you want to store file
copy($HTTP_POST_FILES['ufile']['tmp_name'][0], $path1);
copy($HTTP_POST_FILES['ufile']['tmp_name'][1], $path2);

// Use this code to display the error or success.

$filesize1=$HTTP_POST_FILES['ufile']['size'][0];
$filesize2=$HTTP_POST_FILES['ufile']['size'][1];


if($filesize1 || $filesize2!= 0) 
{
echo "We have recieved your files";
}
else {
echo "ERROR.....";
}

// What files that have a problem? (if found)

if($filesize1==0) {
echo "There're something error in your first file";
echo "&lt;BR /&gt;";
}

if($filesize2==0) {
echo "There're something error in your second file";
echo "&lt;BR /&gt;";
}
?&gt;
</code></pre>

<p>Here is my Question:
If it's possible for example, I upload samplefile.ppt and the other user upload a same filename and file type(samplefile.ppt).. if is posible the newly upload will have a filename like samplefile(1).ppt or samplefile_1.ppt because there was a exsisting file, and when other user upload again, the file will became samplefile(2).ppt or samplefile_2.ppt.
thank you </p>
