Hi.
I want to get extension of uploaded image.
Can you guidance me ?
How can we get extension of uploaded image ?
Moderator: General Moderators
Re: How can we get extension of uploaded image ?
You don't really want to go for the extension. You want to analyze what type of image it is and make your own extension.
For example,
Hope this helps 
For example,
Code: Select all
if (!empty($_FILES['fieldname']['tmp_name']))
{
if (!$imgInfo = @getimagesize($_FILES['fieldname']['tmp_name']))
{
die('You did not upload an image.');
} else
{
switch ($imgInfo[2])
{
case 1:
$imgExtension = '.gif';
break;
case 2:
$imgExtension = '.jpg';
break;
case 3:
$imgExtension = '.png';
break;
//etc
}
}
}Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Re: How can we get extension of uploaded image ?
Thank you very much.
I have a question :
What is it in your code : $imgInfo[2]
I have a question :
What is it in your code : $imgInfo[2]
Re: How can we get extension of uploaded image ?
$imgInfo is the array returned by getimagesize()
[0] index returns the width of the image
[1] index returns the height of the image
[2] index returns the type of image (we wanted the type to determine the extension)
[3] and [4] contain some more information about the image as well
[0] index returns the width of the image
[1] index returns the height of the image
[2] index returns the type of image (we wanted the type to determine the extension)
[3] and [4] contain some more information about the image as well
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Re: How can we get extension of uploaded image ?
Thank you my friend . 