My uploader allows the following file formats:
jpg
pdf
gif
png
I tested that if someone was to name a file configure.php.jpg, my uploader allows it to upload
I want to do a check to see if the user has 2 extensions, and if so it will not allow them to upload.
I was thinking of just checking if the file name has two "." (dots) in the name. What function could I use to do this?
Or .. is there a better way?
determine if file name has 2 dots in it
Moderator: General Moderators
Re: determine if file name has 2 dots in it
For simplicity's sake, I'd use substr_count.
Re: determine if file name has 2 dots in it
Why would it matter if a file name has two dots? If you're worried about the content of a file, check the content, not the file name. Disallowing "configure.php.jpg" but allowing "configure.jpg" does not prevent someone from uploading a file containing PHP. If you want files named a certain way, rename them. Why cause trouble for users who want to upload files with names like "version_1.0.gif", "date_2010.10.11.png", or "forums.devnetwork.net.jpg"?