Forum Moderators: coopster

Message Too Old, No Replies

rename image in function

Adding user id to image

         

Gruessle

10:36 pm on Feb 19, 2005 (gmt 0)

10+ Year Member



Following works, it shows the uid to be 4:
echo "uid: $uid";

In the following funktion I am trying to add the uid in front of every file name.
With $uid.$file_orig it just keeps the file name no uid;
With "$uid-$file_orig" it only adds the '-' to the file name

function do_upload($upload_dir, $upload_url) {

$temp_name = $_FILES['userfile']['tmp_name'];
$file_orig = $_FILES['userfile']['name'];

$file_name = $uid.$file_orig;

$file_type = $_FILES['userfile']['type'];
$file_size = $_FILES['userfile']['size'];
$result = $_FILES['userfile']['error'];
$file_url = $upload_url.$file_name;
$file_path = $upload_dir.$file_name;

[edited by: ergophobe at 11:04 pm (utc) on Feb. 19, 2005]
[edit reason] URL deleted as per Terms of Service [/edit]

ergophobe

11:09 pm on Feb 19, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Are you echoing the value of $uid from within the function? It may be a problem with scope.

For a long explanation of variable scope in functions, see message 7 of

[webmasterworld.com...]

Gruessle

1:53 am on Feb 20, 2005 (gmt 0)

10+ Year Member



Thank you ergophobe,

That is one good tutorial on funktions.
Just what I needed.