Hello.
I allow my users to upload an image to my server. This works, cool. But it is within the human nature to abuse things, and this is why I must include some way of checking a few things before the file is accepted on the server's directory, and not shot down on sight (removed).
The file must be a JPG (JPEG) image, that is no bigger than 30kB and it can't be more than 400 pixels wide nor more than 400 pixels tall.
I can do the math myself, but reading such stuff from the image is where I need help.
To put it short, I need to read the file's actual type (the file extension could lie), size in kiloBytes, width and height.
Now the system could allow any registered user to upload a filthy movie or anything to my server, even a file with a virus! That's just horrible...
Thank you all.
Checking the format of a file, and other stuff
Moderator: General Moderators
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
getimagesize() returns the type information, width and height. filesize() will tell you the size in bytes. Divide that by 1024 and you get in kilobytes.