auto rename of file when its already exist.. PHP CODE
<p><strong>upload.php</strong></p>

<pre><code>&lt;form enctype="multipart/form-data" action="uploader.php" method="POST"&gt;
Choose a file: &lt;input name="uploadedfile" type="file" /&gt;&lt;br /&gt;
Choose a file1: &lt;input name="uploadedfile1" type="file" /&gt;&lt;br /&gt;
&lt;input type="submit" value="Upload File" /&gt;
&lt;/form&gt;
</code></pre>

<p><img src="http://i.stack.imgur.com/PsyiK.jpg" alt="screen capture of upload form"></p>

<p>^<em>Image of the upload.php</em>^</p>

<p><strong>uploader.php</strong></p>

<pre><code>&lt;?php
mysql_select_db("test");

$target_path = "uploads/" . basename( $_FILES['uploadedfile']['name']);
$target_path1 = "upload1/" . basename( $_FILES['uploadedfile1']['name']);
$currentfile = $_FILES['uploadedfile']['name']; 
$currentfile1 = $_FILES['uploadedfile1']['name']; 

$dbfiles = mysql_query("SELECT * FROM new WHERE amount='$currentfile' || amount='$currentfile1'");
if(mysql_num_rows($dbfiles) &gt; 0 )
{ 



}
else
{
        if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path))
        {
                echo "file1: ".$_FILES['uploadedfile']['name']."&lt;br&gt;";
                $file1 = basename( $_FILES['uploadedfile']['name']);
                mysql_query("insert into new (amount) values('$file1')");   
        }
        if(move_uploaded_file($_FILES['uploadedfile1']['tmp_name'], $target_path1))
        {
                echo "file2: ".basename( $_FILES['uploadedfile1']['name']);
                $file2 = basename( $_FILES['uploadedfile1']['name']);
                mysql_query("insert into new (amount) values('$file2')");   
        }
}
?&gt;
</code></pre>

<p><strong>introduction and the problem</strong></p>

<p>This code will allow the user to upload 2 files, then their respective file name will save to the new(<em>name of table</em>) , I need it to save in table so that i have history who was the uploader of the file and simply can retrieve it or download it. The first button is the uploadedfile where in the file will save in <em>uploads</em> folder, then the button below is the uploadedfile1 where in the file will save in <em>upload1</em>, when the user put 2 files in this 2 buttons, then the user click save, it will save to their prepared folder(<em>uploads or upload1</em>), when the user only attach one file whether in the button uploaderfile or uploaderfile1 and click Upload file/save/submit, it will still save its file name to table <em>new</em> and save the file in the following folder(<em>uploads of upload1</em>).</p>

<p>The Problem is when the user upload a same file name, For example abc.jpg is already exist in table <em>new</em> and in folder(<em>uploads of upload1</em>), but there some user also upload abc.jpg.. the problem is in the folder(<em>uploads of upload1</em>) the abc.jpg will only one(one pcs..) because same file name.. i think the solution is the rename, where in the abc.jpg that is currently uploaded will became abc_1.jpg, also in the table <em>new</em> abc_1.jpg will be save..</p>
