Hi I am allowing users to upload files to my site.
However I would like to restrict them to just PDF, word files and powerpoint presentations.
Is there a function like getimagesize to allow this?
finding a file type
Moderator: General Moderators
-
timclaason
- Forum Commoner
- Posts: 77
- Joined: Tue Dec 16, 2003 9:06 am
- Location: WI
File types
I would use substr().
For instance:
or preg_match() or some other string function.
For instance:
Code: Select all
if(substr($_FILES['theimage']['name'], -4) != ".doc") {
print("Invalid File Type");
}And if I upload an vbscript that I named funny.gif (or funny.doc)? This really worked in IE some time ago and the script got executed. Don't rely on a simple file suffix.
Take a look at http://de2.php.net/ref.mime-magic
Take a look at http://de2.php.net/ref.mime-magic