Jump to content

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..

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

 

My bad, sorry.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.