I have a script that is supposed to take an image and convert it to a .jpg. This is the code that makes it happen:
$uploadDir = $_SERVER['DOCUMENT_ROOT'] . "/blogimages/";
$tempFile = ereg_replace("'", "_", basename($_FILES['newsImg']['name']));
$uploadFile = $uploadDir . $tempFile;
move_uploaded_file($_FILES['newsImg']['tmp_name'], $uploadFile);
$newPic = $uploadDir . $blogID . ".jpg";
if(file_exists($newPic)){
unlink($newPic);
}
$convertString = "$IM -strip $uploadFile $newPic";
echo "<!-- $convertString -->";
exec($convertString);
as can be seen I put the final string in an HTML comment so I can see what is being executed. What happens is that the converted image is created, but it is a 0 byte image. So no data is actually written to the file. Just to make sure convert is actually working like it normally should I copy and pasted the convert string from the html comment to a command line and it works just fine. It only seems to be having problems within the PHP exec. Any thoughts on why this might be?