Copy link to clipboard
Copied
HI Folks,
I am trying to rename a file uploaded in a form using this.
But nothing happens. I can't figure out why but I'm sure you guys will see the problem straight away.
if(isset($_FILES['logo']['name']))
{$_FILES['logo']['name']=("".$row_rs_member['id']."jpg");}
Any ideas?
Dave
Copy link to clipboard
Copied
Take a look at move_uploaded_file function:
http://php.net/manual/en/function.move-uploaded-file.php
In your case, something like this should work:
$filename = $row_rs_member['id'] . ".jpg";
$filepath = "/home/username/html/files/"; // CHANGE THIS WITH YOUR OWN PATH...
move_uploaded_file($_FILES['logo']['tmp_name'], $filepath . $filename);
Copy link to clipboard
Copied
Thanks but I'm confused.
I don't want to move the file.
It's aldready being uploaded to the right folder, just with the existing name. `so if I can just change the filename before it's uploaded everything will work perfectly.
Isn't there just a straightforward way of renaming the file?
Dave
Copy link to clipboard
Copied
Yes there is:
http://www.php.net/manual/en/function.rename.php
![]()
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more