Kairu Posted December 23, 2006 Share Posted December 23, 2006 Alright, I'm having a bit of a problem. When I put my code together I did not anticipate php files outputting different file types.I was using this for a short time to separate file types before I tried to use a php file...[code]if (strpos($sig, '.jpg') !== FALSE) {$image = imagecreatefromjpeg($sig);}elseif (strpos($sig, '.png') !== FALSE) {$image = imagecreatefrompng($sig);}elseif (strpos($sig, '.gif') !== FALSE) {$image = imagecreatefromgif($sig);}elseif (strpos($sig, '.bmp') !== FALSE) {$image = imagecreatefromwbmp($sig);}else {$image = imagecreatefromgif($sig);}[/code]Is there a better way to do this? Or perhaps one will work for all file types? I guess I could request the files be the same, but that would bee too much trouble if they do not have access to the file.....Any help would be appreciated! Link to comment https://forums.phpfreaks.com/topic/31651-solved-imagecreatefromtype-detector-help/ Share on other sites More sharing options...
brendandonhue Posted December 23, 2006 Share Posted December 23, 2006 A filename ending in ".jpg" doesn't guarantee the file is actually a JPEG.Take a look at imagecreatefromstring() Link to comment https://forums.phpfreaks.com/topic/31651-solved-imagecreatefromtype-detector-help/#findComment-146701 Share on other sites More sharing options...
Kairu Posted December 23, 2006 Author Share Posted December 23, 2006 Aaaahhhhhh....... I couldent get it to work at first, but then found an example.... You need to place file_get_contents() into it to make it work.... correct? Link to comment https://forums.phpfreaks.com/topic/31651-solved-imagecreatefromtype-detector-help/#findComment-146704 Share on other sites More sharing options...
brendandonhue Posted December 23, 2006 Share Posted December 23, 2006 Yes Link to comment https://forums.phpfreaks.com/topic/31651-solved-imagecreatefromtype-detector-help/#findComment-146707 Share on other sites More sharing options...
Kairu Posted December 23, 2006 Author Share Posted December 23, 2006 Thank you! Link to comment https://forums.phpfreaks.com/topic/31651-solved-imagecreatefromtype-detector-help/#findComment-146708 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.