Lamez Posted March 23, 2008 Share Posted March 23, 2008 1. I am working with images, and is there a function where I can resize a picture? 2.This is one is kinda hard to explain, so let me explain what I need a certain function for: Alright, when a user uploads a image, I want the script to delete their old one, well the image name is hased, except the last part of the name is their username. The image name looks like this: 5c435de5d9db471ca31b5b028eaf2acd-lamez.png here is the code to get the image name. md5($new_filename)."-".$user.".".getExt($bfilename); as you can see, before the extension is their username, so is there a function that can take last part of the filename before the extension, and tell if it is the user that is trying to upload a new image? Quote Link to comment https://forums.phpfreaks.com/topic/97466-functions-questions/ Share on other sites More sharing options...
wildteen88 Posted March 23, 2008 Share Posted March 23, 2008 1. I am working with images, and is there a function where I can resize a picture? Yes look into [http://www.php.net/gd]GD[/url] or search the forums. There have been many questions about resizing images with GD. 2.This is one is kinda hard to explain, so let me explain what I need a certain function for: Alright, when a user uploads a image, I want the script to delete their old one, well the image name is hased, except the last part of the name is their username. The image name looks like this: 5c435de5d9db471ca31b5b028eaf2acd-lamez.png here is the code to get the image name. md5($new_filename)."-".$user.".".getExt($bfilename); as you can see, before the extension is their username, so is there a function that can take last part of the filename before the extension, and tell if it is the user that is trying to upload a new image? To retrieve the username from the filename of a file use: $image = '5c435de5d9db471ca31b5b028eaf2acd-lamez.png'; list($image_name_hash, $username) = explode('-', pathinfo($image, PATHINFO_FILENAME)); echo 'Hash: ' . $image_name_hash . '<br />'; echo 'Username: ' . $username; Quote Link to comment https://forums.phpfreaks.com/topic/97466-functions-questions/#findComment-498736 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.