I am using the below code to validate an image.

getimagesize($file['tmp_name'])=== false 

It's working fine in php 5.2 (wamp server local), but not working in live website(php 5.6).

MIME_Content_type is showing that it's an image/jpeg, but it's not an image.

What should I do?

I am using joomla 3.10

  • Is this a Joomla-centric question? It seems to be a matter of pure php. Did you search Stackoverflow?
    – mickmackusa
    Aug 24, 2018 at 11:07
  • Are you getting any errors in your error log? Did you see this? stackoverflow.com/q/3121547/2943403 What is the file type being uploaded? Please offer more details. stackoverflow.com/q/12761445/2943403
    – mickmackusa
    Aug 24, 2018 at 11:17
  • Are you referencing $_FILES with your $file variable? stackoverflow.com/a/6755263/2943403
    – mickmackusa
    Aug 24, 2018 at 11:29
  • I need to check image before uploading in joomla. when i checked MIME TYPE it's showing image/jpeg but it's not an image. The audit team provided the image which mime type is image but it's a exe file. Please suggest me what should i do...?
    – mohan
    Aug 30, 2018 at 5:36
  • Which of these solutions have you tried so far? stackoverflow.com/q/6755192/2943403 If you can solve your own question after researching and testing, please answer your own question and mark it with the green tick.
    – mickmackusa
    Aug 30, 2018 at 5:44

1 Answer 1


According to PHP documentation, getimagesize() should not be used to check if file is an image:

This function expects filename to be a valid image file. If a non-image file is supplied, it may be incorrectly detected as an image and the function will return successfully, but the array may contain nonsensical values.

Do not use getimagesize() to check that a given file is a valid image. Use a purpose-built solution such as the Fileinfo extension instead.


  • i got your point sir.. Can you suggest me any joomla or php function with the help of which i can findout the file content...
    – mohan
    Sep 1, 2018 at 6:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.