this is in no way complete but hopefully it will get you going in the right direction.
All it does is take the uploaded file named "$myfile" and renames it by prepending the user name and a hyphen to the original name.
When you need to get the right file, just use :
PHP Code:
$ar = explode("-",$image_file_name);
$user_name = $ar[0];
this is assuming you don't allow hyphens in the user name.
It works pretty well for me, there is about 140,000 images that were uploaded this way so far and no problems.
form:
Code:
<form ENCTYPE="multipart/form-data" method=post action=process_upload.php>
<input name=myfile type=file>
<input type=submit value="Click to upload">
</form>
process_upload:
PHP Code:
//get the original file name
$og_name = $HTTP_POST_FILES['userfile']['name'];
//set the path where it is going to go
$path = "/my/path/";
//set the new file name by prepending the user name to the original file name
$new_file_name = $path.$user_name."-".$og_name;
//move it
move_uploaded_file($myfile,$new_file_name);