Results 1 to 3 of 3

Thread: Secure Uploading

  1. #1
    Join Date
    Aug 2005
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Secure Uploading

    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?

  2. #2
    Join Date
    Aug 2004
    Location
    Brighton
    Posts
    1,563
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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;
    	}
    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.

    cr3
    A retired member, drop me a line through my site if you'd like to find me!
    cr3ative media | read the stickies

  3. #3
    Join Date
    Aug 2005
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Cheers

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •