Jump to content

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

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.