Jump to content

check filetype


jonniejoejonson

Recommended Posts

You could also explode it into a string

 

$filename = "whatever.vr1.jpeg"; // I have multiple periods to show you that the code below will still work

$filename_arr = explode(".",$filename);
$filetype = $filename_arr[(count($filename_arr) - 1)];
if($filetype == "jpeg" || $filetype == "gif"){
// is a jpeg or a gif
}else{
// error only jpeg or gif is allowed
}

Link to comment
https://forums.phpfreaks.com/topic/84189-check-filetype/#findComment-428629
Share on other sites

Thanks guys,

 

Do you think that the following is enough protection when allowing people to copy ONLY jpeg or giff images from a server to your server?

 

$contentType=mime_content_type($urlImage);

 

if($contentType=='image/gif'||$contentType=='image/jpeg'){

copy($urlImage,"../images/".$saveImg)or die ('Could not copy'); }

else

{exit();}

 

 

thanks J.

Link to comment
https://forums.phpfreaks.com/topic/84189-check-filetype/#findComment-428716
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.