php imagejpeg():无法打开'/pic/upload/123.jpg'进行写入:没有这样的文件或目录

时间:2014-10-28 12:45:42

标签: php ftp

我几天后一直在寻找如何解决这个问题并尝试了我在这里找到的所有内容。我不是很擅长php,所以我希望有人能比我更快地找到问题:)

权限是777 图片上传到/ pic / tmp ...我也尝试更改上传到/ pic这都没问题.... ...只有当我想用imagejpeg()

做某事时

感谢您的帮助!

(有些尝试已经注意到了// ....但不是我尝试的所有内容)

<?php
$ftp_server = "adress";
$ftp_user_name = "user";
$ftp_user_pass = "password";

$destination_file = "/pic/upload/tmp/". basename($_FILES['file']['name']);
$uploaddir="/pic/upload/tmp/";
$newpath="/pic/upload/";
$ftppath="ftp://".$ftp_user_name.":".$ftp_user_pass."@".$ftp_server;
$source_file = $_FILES['file']['tmp_name'];

$conn_id = ftp_connect($ftp_server);
ftp_pasv($conn_id, true); 
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); 

$upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY); 

$alterPfad=$ftppath.$uploaddir."123.jpg";
$neuerPfad=$newpath."123.jpg";
//$neuerPfad=$ftppath.$newpath."123.jpg";
//$neuerPfad=".".$newpath."123.jpg";

$bildEigenschaft = getimagesize($alterPfad); 
$widthOld = $bildEigenschaft[0]; 
$heightOld = $bildEigenschaft[1]; 
$image_filetype = $bildEigenschaft[2]; 

$width=$widthOld;
$height=$heightOld;
    if($width>670)
        {list($width,$height)=Groessenberechnung($width,$height,670);
        }
    if($height>500)
        {echo "<p>berechnung 2.1 weite:".$width." hoehe:".$height."</p>";
        list($height,$width)=Groessenberechnung($height,$width,500);
        }

$image_old = imagecreatefromjpeg($alterPfad); 
$image_new = imagecreatetruecolor($width, $height); 

imagecopyresampled($image_new, $image_old, 0, 0, 0, 0, $width, $height, $widthOld, $heightOld); 

//tp_rename($conn_id,$destination_file,$uploaddir."123.jpg");   //ftp_put($conn_id,"/pic/upload/123.jpg","/pic/upload/tmp/123.jpg", FTP_BINARY); 
//ftp_raw($conn_id,imagejpeg($image_new,$neuerPfad)); 
    imagejpeg($image_new,$neuerPfad);
...
...
...
?>

1 个答案:

答案 0 :(得分:0)

我会echo $neuerPfad的值来查看它尝试打开的路径。