我一遍又一遍地阅读我的代码,但我无法弄清楚什么是错的..
脚本:
<?
require_once("../constant/constant.php");
if($_POST['action'] == 'imgsave'){
$admin = $_POST['admin'];
$profile = $_POST['profile'];
$sth = $conn->prepare("SELECT * FROM profiles WHERE profile_id = '".$profile."'");
$sth->execute();
$row = $sth->fetch(PDO::FETCH_ASSOC);
$targ_w = 180;
$targ_h = 120;
$src = imagecreatefromjpeg('../uploads/'.$profile.'.jpg');
$tmp = imagecreatetruecolor($targ_w, $targ_h);
imagecopyresampled($tmp, $src, 0,0,$_POST['x'],$_POST['y'],$targ_w,$targ_h,$_POST['w'],$_POST['h']);
//Grab new image
ob_start();
imagejpeg($tmp);
$image = ob_get_contents();
ob_end_clean();
imagedestroy($tmp);
imagedestroy($src);
//Create temporary file and write to it
$fp = tmpfile();
fwrite($fp, $image);
rewind($fp);
//Upload new image
$conn_id = ftp_connect('ftp.test.com');
ftp_login($conn_id,'user','pass');
ftp_fput($conn_id,'/profiles/'.$row['path'].'/preview2.jpg', $fp, FTP_BINARY);
fclose($fp);
}
?>
它与 jCrop 脚本相结合,我想要的只是修改原始脚本以将其发布到 FTP ..
$src = imagecreatefromjpeg($folder.$filename);
$tmp = imagecreatetruecolor($targ_w, $targ_h);
imagecopyresampled($tmp, $src, 0,0,$_POST['x'],$_POST['y'],$targ_w,$targ_h,$_POST['w'],$_POST['h']);
imagejpeg($tmp, $folder.'t_'.$filename,100);
imagedestroy($tmp);
imagedestroy($src);
如您所见,原始脚本非常简单..而且我想我陷入了它变得多么先进的问题..任何人都可以看到解决方案,或者给我一个提示,告诉我还有什么可以做的..