Jump to content

Functions Questions


Lamez

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/97466-functions-questions/
Share on other sites

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;

Link to comment
https://forums.phpfreaks.com/topic/97466-functions-questions/#findComment-498736
Share on other sites

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.