Jump to content

[SOLVED] Help renaming a file


graham23s

Recommended Posts

Hi Guys,

 

when a user uploads an image file i delete the name of the file and append a random 8 digit number to it (keeping the files original extension)

 

so : graham23spic.jpg would be 12345678.jpg, i was wanting to add an extra bit of text to the end of the photo kinda like: 12345678.jpg-Users_Photo

 

but i'm not sure how to do this my rename code is:

 

	 // renamed avatar...////////////////////////////////////////////////////////////////
 $renamed_avatar = $random_number.".".substr($_FILES["avatar"]["name"],strtolower(strlen($_FILES["avatar"]["name"]))-3,3); 

 

any help would be appreciated

 

thanks guys

 

Graham

Link to comment
https://forums.phpfreaks.com/topic/54085-solved-help-renaming-a-file/
Share on other sites

// renamed avatar...////////////////////////////////////////////////////////////////
$renamed_avatar = "{$random_number}." . substr($_FILES["avatar"]["name"] . strtolower(strlen($_FILES["avatar"]["name"]))-3,3) . "Users_Photo";

 

I really wouldn't recommend putting text after the extension though..

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.