Thanks for the advice guys.
Yeah.. I figured I'll have to do something like this. The trouble of course is that with a database I can't run any of the mime checking functions as they work with physical files. So I have to pull the image from the database, make a file out of it, detect the header, do stuff with that, and then pull the same image out of the database again to actually display it within the browser. Not very efficient when you have other better things you could spend server time on. Modifying the database is a better option indeed it seems. It might take longer initially but in the long run it will save a lot of headache.
By the way, I found a way to obtain the image using my image.php?name=imagename scheme. Normally if you feed something like "image.php?name=imagename" into getimagesize() it will not find it to be a valid file, for obvious reasons. All you do is run the script from the console, pass the needed parameters as arguments, and then convert the $argv array into the appropriate $_GET entries. That way the image.php script requires very little modification. Eg.:
// grab the output and feed the arguments in
$image = shell_exec("php image.php name=imagename");
// inside of image.php: the passed arguments are part of the superglobal $argv array. 'name=imagename' is $argv[1]. $argv[0] is the script name.
if ($argv)
for ($i=1;$i<count($argv);$i++)
{
$it = split("=",$argv[$i]); // split our string into appropriate $_GET array entries
$_GET[$it[0]] = $it[1];
}
Will probably come in handy somewhere down the line or maybe someone else might find it useful. Gotta love programming - a learning experience every time!
I'm such a nerd... :rolleyes: