Jump to content

[SOLVED] imagecreatefrom[type]() detector help


Kairu

Recommended Posts

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

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.