Php make dir using text name and rename upload file
<p>Html sample code:</p>

<pre><code>&lt;html&gt;
&lt;body&gt;
&lt;form enctype="multipart/form-data" action="upload.php" method="POST"&gt;
Company Name:&lt;input type="text" name="company"/&gt;&lt;br /&gt;
ClientName: &lt;input type="text" name="ClientName"/&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;input type="hidden" name="MAX_FILE_SIZE" value="5120000" /&gt;
 Send this file: &lt;input name="userfile" type="file" /&gt;
&lt;input type="submit" value="Send File" /&gt;
&lt;/form&gt;
&lt;/body&gt;
</code></pre>

<p></p>

<p>Sample Php code:</p>

<pre><code>&lt;?php

$file_name = $_POST['company'];
$random_digit = rand(0000,9999);
$new_file_name = $random_digit.$file_name;

$uploaddir = 'c:/temp/'.$new_file_name;
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);

echo "&lt;p&gt;";
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
echo "File is valid, and was successfully uploaded.\n";
} else {
echo "Upload failed";
}

echo "&lt;/p&gt;";
echo '&lt;pre&gt;';
echo 'Here is some more debugging info:';
print_r($_FILES);
echo '['.$new_file_name.']';
print "&lt;/pre&gt;";
?&gt; 
</code></pre>

<p>I am having problem with the rename. It renames the file but it keeps the original name too.  So if I upload a file name joey.doc, it changes to random# = 4567, company name = whatever, file name = joey.doc  output = 4567whateverjoey.doc.   What I am looking for is for the file name to change to the random number append the company only = 4567whatever.doc. Later I will write code to create company name directory store all file from that company in their directory. Store the location tag in xml then pull up a table with to reference. the information. Plus I use the client name input box to decode what file go with what.</p>

<p>If writing xml is like asp.net C# I should have no problem </p>
