I have a MySQL table in which I store user avatars as a blob. I fetch those images with a script called avatar.php which outputs the image. To request a specific user image, you have to call avatar.php?id=(user id). To make the dynamic image name pretty, I added an URL rewrite in my .htaccess so you can also call avatar-(userid).jpg, which will translate in avatar.php?id=(userid).
Now I want to fetch the user image and manipulate it using GD. I tried using getimagesize() and imagecreatefromjpeg() but I’m continuously getting an “failed to open stream no such file or directory” error.. Both the script in which I try to use these functions, as the avatar.php script, are in the root directory. I tried:
getimagesize('avatar.php?id=1');
getimagesize('./avatar.php?id=1');
getimagesize('/avatar.php?id=1');
...and the same but using avatar-1.jpg instead.
When I use the full url of my site (including http:// etc.) it actually works… But I haven’t found out why.
//Edit:
Similar problem occurs when using the file_exists() function. If I try file_exists(‘./avatar.php’) it returns true, if I add get-vars it returns false. Are these functions unsuitable for dynamic files?
Could someone help me out please?
Thanks in advance
If you just want the image size without any manipulation you can use getimagesizefromstring