Hello,
I’m working on a php script that reads in all of the image files in a specified directory and then saves out thumbnail versions of each image file to that same directory, using the imagepng function.
This script works wonderfully, but only as long as the my php script is being executed from the same directory as the one I’m passing to imagepng. So if my images are in $_SERVER[‘DOCUMENT_ROOT’]/images/, my .php script needs to be in that directory as well or imagepng will return false.
Any ideas on how I might be able to get around this? For reference, my code looks like this (pseudo code):
[php]$thumbImage //my image Resource, correctly created, resized, and ready to go.
$dir //my destination directory which I’ve read the images from and will now be saving thumbnails to the path is based off of $_SERVER[‘DOCUMENT_ROOT’], rather than a URL.
imagepng($thumbImage, $dir); //Succeeds if my script is in $dir, fails otherwise.[/php]
Thanks very much for the help!