How can I restrict the type of file that a person uploads when I allow them to upload and edit the file to my server through an web-browser using PHP?![]()
How can I restrict the type of file that a person uploads when I allow them to upload and edit the file to my server through an web-browser using PHP?![]()
That's a code extract from my upload script at www.b3ta.cr3ation.co.uk - it's from a php which is POST'ed to. Hopefully it'll give you some ideas and allow you to adapt it to your variable names.Code:$allowed_types = array( "image/gif" => "gif", "image/pjpeg" => "jpg", "image/jpeg" => "jpg", "image/jpeg" => "jpeg", "image/bmp" => "bmp", "image/png" => "png", ); if(!array_key_exists($_FILES['userfile']['type'], $allowed_types)) { echo ("Bad type."); exit; }
cr3
A retired member, drop me a line through my site if you'd like to find me!
cr3ative media | read the stickies
Cheers
Bookmarks