Javascript PHP imagejpeg()在服务器上不工作
我正在为我的网站开发图像裁剪功能。我给我的PHP脚本发送了一个裁剪图像尺寸x、y、宽度和高度的数组 脚本成功地在本地主机上裁剪图像,但在推送到web服务器时不起作用Javascript PHP imagejpeg()在服务器上不工作,javascript,php,jquery,ajax,image,Javascript,Php,Jquery,Ajax,Image,我正在为我的网站开发图像裁剪功能。我给我的PHP脚本发送了一个裁剪图像尺寸x、y、宽度和高度的数组 脚本成功地在本地主机上裁剪图像,但在推送到web服务器时不起作用 <?php $array = json_decode(file_get_contents('php://input')); $targ_w = 542; $targ_h = 671; $src = $array[0]; $img_r = imagecreatefromjpeg($sr
<?php
$array = json_decode(file_get_contents('php://input'));
$targ_w = 542;
$targ_h = 671;
$src = $array[0];
$img_r = imagecreatefromjpeg($src);
$dst_r = ImageCreateTrueColor( $targ_w, $targ_h );
imagecopyresampled($dst_r,$img_r,0,0,$array[1],$array[2],
$targ_w,$targ_h,$array[3],$array[4]);
$time = time();
if (imagejpeg($dst_r, 'temp_crops/temp_'.$time.'.jpg'))
echo "made it";
else
echo "didnt make it :(";
//echo $time;
?>
本地主机的响应是:成功了。
Web服务器响应为:未成功:
有谁能帮我一下,告诉我为什么这样不行吗?谢谢 检查GD库-在脚本中使用if!函数_存在“imagejpeg”。。。
否则,错误日志可能会出现在/var/log/httpd/中,该错误表示您的PHP脚本没有权限写入服务器上的该位置。使用FTP软件更改权限,以允许写入您试图存储这些权限的目录。除非您的Web主机已禁止PHP在本地写入文件,否则应该这样做。在这种情况下,您应该与他们交谈,看看有哪些选项可用。服务器是否安装了GD?仔细检查服务器上的错误日志,查看是否发生了错误。我不确定错误日志在哪里。我检查了var/log/apache2,但没有apache2文件夹。debian/ubuntu系统日志位于/var/log/apache2中
$('#crop_modal').on('hidden.bs.modal', function () {
var array = [$('#profile_preview').attr('src'), $('#x').val(), $('#y').val(), $('#w').val(), $('#h').val()];
if (checkCoords()) {
$.ajax({
url : '../../application/views/poster/crop.php',
type: 'POST',
data : JSON.stringify(array),
success: function(data) {
console.log(data)
$('#profile_preview').attr('src', '../../application/views/poster/temp_crops/temp_'+data+".jpg");
$('#final_img_src').val('temp_'+data+'.jpg');
}
});
}
});