The SitePoint Forums have moved.

You can now find them here.
This forum is now closed to new posts, but you can browse existing content.
You can find out more information about the move and how to open a new account (if necessary) here.
If you get stuck you can get support by emailing forums@sitepoint.com

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Thanks

Thank you for your reply.

Could you please explain, for my education, what this code does, please?
And when you say "$account->get_user_name() should be validated", would you mind telling me what that means. Is that something I need to do? Thanks

And, once a file gets uploaded this code will automatically change the name of the file to the User Name, keep the extension, and move it to the location specified, as is? Or is there something I need to add, modify or substitute?

Thanks again so much for your help. I really appreciate it.
I added your code to this file, which is where I believe it should go, but I'm guessing. It didn't change the file name. So I am hoping you could please just look this file over. You'll see that the code shows a directory named "Files" that upload files are sent to. So I don't know if the code you provided to me conflicts with this code or not. Or if your code should replace some code in the file I've pasted below (without your code). If you could look at it and give me your expert opinion, I'd be very grateful Thanks.

<?
// Begin options

$allow_file_deletion = false; // To allow visitors to delete files, leave this at true; otherwise, change it to false

$result = move_uploaded_file($temporary, $file_path);
if(!chmod($file_path,0777))
$message = "ERROR: A folder to place the files was not found, or the files need to be CHMODed to 777.";
else $message = ($result)?"File has been uploaded." : "An error has occurred.";
return $message;
}
?>

function upload_file($upload_directory,$upload_uri){$file_name=$_FILES["userfile"]["name"];$file_name=str_replace(" ","_",$file_name);$ext=pathinfo($file_name,PATHINFO_EXTENSION);$file_path=$upload_directory.$account->get_user_name().'.'.$ext;$temporary=$_FILES["userfile"]["tmp_name"];$result=move_uploaded_file($temporary,$file_path);if(!chmod($file_path,0777))$message="ERROR: A folder to place the files was not found, or the files need to be CHMODed to 777.";else$message=($result)?"File has been uploaded.":"An error has occurred.";return$message;}

$result = move_uploaded_file($temporary, $file_path);
if(!chmod($file_path,0777))
$message = "ERROR: A folder to place the files was not found, or the files need to be CHMODed to 777.";
else $message = ($result)?"File has been uploaded." : "An error has occurred.";
return $message;
}
?>

Mystery solved

It seems I've solved this mystery. Your code IS working in the Upload page. It seems there was one file in the /files/ directory with the user name, and because I was testing this with the same User Name, files were being renamed, but weren't being allowed into the /files/ directory because there was already one single file with that same name.

So I don't know where the disallowed files were going, but obviously I need to empty the /files/ directory often.

Would you be interested in telling me how I might direct files to an email address instead of the /files/ directory? So the several files, with the same name, could be stored? Or you may have another (better) idea?