Jump to content

Recommended Posts

check the extension. by exploding the file name.

$string = "lala.mama.jaja.yaya.tata.moemoe.jpg";

$myarray = explode('.', $string);

$extension = $myarray[count($myarray)-1]; // gets the last part
echo $extension; // outputs jpg

From there on you only need to check the value of $extension to what you expect, in this case a jpg.

 

or do something like this:

 

 echo substr(basename($string), -3); // outputs jpg 

 

The getimagesize returned index [2] is an integer (the IMAGETYPE_JPEG defined constant has the value 2.) Index [4] is the mime type.

 

I would troubleshoot what value you are getting by using var_dump() on the returned value and given that you have an @ on the getimagesize statement to suppress errors, it is likely some other problem is occurring before that point. What php error, if any, do you get when you remove the @?

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.