I'm trying to convert PDF files to JPG using the comand line call in PHP
here's my code:
Code: Select all
<?php
$dir = "/var/www/vhosts/domain/httpdocs/resources/";
if (!isset($_GET['file'])) { echo('no file seleected'); exit(); }
$file = $_GET['file'];
$path_parts = pathinfo($dir.$file);
echo $path_parts['dirname'], "<br/>";
echo $path_parts['basename'], "<br/>";
echo $path_parts['extension'], "<br/>";
echo $path_parts['filename'], "<br/>";
$command = '"/usr/bin/convert" "' . $dir .$file.'[0]" "' . $dir. $path_parts['filename'].'.jpg"';
echo $command . "<br /><br />";
$result = system($command, $retval);
if ($result==-1) { echo("fail<br /><br />"); }
echo("result:$result<br/><br/>");
echo("returnval:$retval<br/><br/>");
?>
For otehr files it fails.
Here are two example files, one works and one doesn't
http://previewyoursite.co.uk/temp/works.pdf
http://previewyoursite.co.uk/temp/notworks.pdf
I have several examples of files that work and ones that don't but I can't see a common difference between the two.
Thanks