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.

Renaming a file after upload

In another forum posting I requested help with code, to add to a script, that takes a file, after it's uploaded, and renames it with the logged-in users name (and keeps the same file extension) and moves it to a directory folder.

The code below does that successfully when added to the upload script.

I would like to modify this code so it renames uploaded files by combining the uploaded file name with the user name.

For example, Joe, the logged-in users name, uploads a file named MyLife.txt would be renamed MyLife Joe.txt.

Because this code (below) works successfully presently, I'd rather have someone help me modify it rather than provide all new code. Thank you. Any help would be greatly appreciated.

$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;
}

p.s. the script uses $account->get_user_name(); to get the logged-in user name.