Jump to content

How many extension to test for problem


geroid

Recommended Posts

Further to my previous post. I'm checking the extension of an upload to see if it's valid. I only want images file. I have the following questions:

1. Am I including all the possible extensions here? Are there any more I should be including.

2. What is a good max file size limit for an image file?

3. Should I forget the max file size limit and simply resize the image?

4. How do I mark a post as solved?

 

I use the following test:

 

if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "gif"))

{

//print error message

echo '<h3>This is an unknown file extension! Please try again</h3>';

$errors=1;

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/159556-how-many-extension-to-test-for-problem/
Share on other sites

Thanks. I'm looking at getimagesize function now. Can I just ask if the size of an image is important? That is does it matter? If I am going to restrict upload based on the image size, then what should the size limit be and as I said, should I just determine the size and resize accordingly instead of restricting.

Hi thorpe

Just two things. Can you give me a sensible limit to work with? The second thing is this. If I use the getimagesize function to determine if its an image or not will this be safe. What I mean is there are many types of images files. Will getimagesize recognise them but more importantly, would a browser be able to handle them or should I just confine the type tp jpeg, gif, png etc.?

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.