Jump to content

upload photo limits


chris_s_22

Recommended Posts

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

 

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?

if ($uploaded_type =="text/php") 
{ 
echo "No PHP files<br>"; 
$ok=0; 
} 

Link to comment
https://forums.phpfreaks.com/topic/183403-upload-photo-limits/
Share on other sites

$allowed = array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG);
echo ( in_array(exif_imagetype($image), $allowed) ) ? 'good image type':  'invalid image type';
// $image above would be $_FILE['whatever']['tmp_name']

 

Here are the allowed types: http://us2.php.net/manual/en/function.exif-imagetype.php

Link to comment
https://forums.phpfreaks.com/topic/183403-upload-photo-limits/#findComment-968136
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.