photo upload limits

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
chris_s_22
Forum Commoner
Posts: 76
Joined: Wed Dec 31, 2008 2:05 pm

photo upload limits

Post by chris_s_22 »

ive got a upload photo script and im just trying to make more secure currently it limits size and as you can see from my code below it limits only gif and php files

how do i edit my code to limit all these or do i have to copy and paste the same code and change the file extention?
jpg, jpeg, pjpeg, PJPEG, JPG, JPEG, gif, GIF, png, PNG

Code: Select all

if (!($uploaded_type=="image/gif")) {
    echo "You may only upload GIF files.<br>";
    $ok=0;
    }  
 
also ive restricted php is there anything else i need to restrict?

Code: Select all

if ($uploaded_type =="text/php") 
{ 
    echo "No PHP files<br>"; 
    $ok=0; 
    }
chris_s_22
Forum Commoner
Posts: 76
Joined: Wed Dec 31, 2008 2:05 pm

Re: photo upload limits

Post by chris_s_22 »

would this be ok?

Code: Select all

$types = array("type/jpg", "type/jpeg", "type/pjpeg", "type/PJPEG", "type/JPG", "typ/JPEG", "type/gif", "type/GIF", "type/png", "type/PNG");if(!in_array($uploaded_type,$types)){ echo "Invlaid file type"; $ok = 0;}
Post Reply