I have a small php function which uses ghostscript to take a multipage pdf and convert it to multiple pngs. This part of the script works perefctly i can run it and check the images folder and they are all there.
The next part of the script resizes the pngs produced by ghostcript. However any attempt to make use of these pngs in php results in "failed to open stream: No such file or directory"
Moreover if copy one of the generated pngs to another folder or even the same folder it will become readable. This leads me to believe the ghostscript generated images might have the incorrect permissions. But when i run my script to check for permissions and if the file exists. both return false.
Here is the conversion script:
<?php
//Upload pdf convert to pngs in the folder jpgs/originals
$uploaddir = 'uploadtemp/';
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
echo "<p>";
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
exec('bin\gswin32c.exe -o jpgs\originals\%3d.png -sDEVICE=png16m -r150 uploadtemp\input.pdf');
unlink('uploadtemp\input.pdf');
header('Location: main.php');
} else {
echo "Upload failed";
}
?>
Here is the script which tries to call the now generated pngs:
<?php
$filename = "jpgs/originals/1.png";
if (is_writable($filename)) {
echo 'The file is writable';
} else {
echo 'The file is not writable';
}
if (file_exists($filename)) {
echo "The file $filename exists";
} else {
echo "The file $filename does not exist";
?>
Both if statements return false even though i can see the files generated in the folder