I am trying to change the file name before it is stored on the server.
[code]Html sample code:
Company Name:ClientName:
Send this file: [/code]
[php]
<?php $file_name = $_POST['company']; Define ("PATH", "/wamp/www/phpuploader/$file_name"); if(!is_dir($file_name)) { mkdir($file_name); $old_file_name = $file_name; $random_digits = rand(0000,9999); $new_file_name = $file_name.$random_digits; rename( '$old_file_name', '$new_file_name'); $uploaddir = PATH . '/'.$new_file_name; $uploadfile = $uploaddir . basename($_FILES['userfile']['name']); echo ""; if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) { echo "File is valid, and was successfully uploaded.\n"; } else { echo "Upload failed"; } echo "
"; echo ''; echo 'Here is some more debugging info:'; print_r($_FILES); print ""; } ?>
[/php]
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 to it. 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.
If writing xml is like asp.net C# I should have no problem