簡體   English   中英

php imagejpeg()無法打開,沒有此類文件或目錄或權限被拒絕

[英]php imagejpeg() Unable to open, No such file or directory or permission denied

將縮略圖圖像寫入以下目錄時出現以下錯誤

Warning: imagejpeg() [function.imagejpeg]: Unable to open 'D:\imagesdb\images\62t\' for    writing: No such file or directory

如果我手動創建一個目錄,然后將其添加到imagejpeg()例如:C:\\ images我得到相同的錯誤,這也適用於我使用fopen

Warning: fopen(C:\images\) [function.fopen]: failed to open stream: No such file or directory

所有路徑都存在! 我還檢查了varibles以查看路徑是否正確並且我沒有丟失數據,(var_dump!)

我也嘗試過chmod,但我使用的是Windows,這應該不適用?

我在用

Windows XP Home Edition SP3 running localhost, XAMMP, apache, php

我擔心如果它是我正在使用的操作系統版本,我已嘗試在'services'中給apache服務本地系統帳戶訪問,嘗試共享該文件夾!

我可以在上傳到同一目錄中的另一個文件夾'images \\ 62'上寫一個正常的圖像,但是'images \\ 62t'要么被拒絕,要么在我試着寫拇指時不存在?

我已經檢查過php.ini,gd已啟用,我嘗試取消注釋:extension = php_gd2.dll,安全模式也關閉。

我擔心如果它是我的操作系統版本,它在文件權限方面有限嗎? 或者只是我的代碼?

if($this->changed){
    //$tp = fopen("C:\images\\",'w+');
    chmod($this->thumb_path, 0777);
    $originalImage = imagecreatefromjpeg($this->image_path);
    $width = imagesx($originalImage);
    $height = imagesy($originalImage);

    $thumb_width = $this->thumbWidth;
    $thumb_height = floor($height * ($this->thumbWidth / $width));
    $newImage = imagecreatetruecolor($thumb_width,$thumb_height);
    imagecopyresized($newImage,$originalImage, 0, 0, 0, 0, $thumb_width, $thumb_height,  $width, $height );
    imagejpeg($newImage,$this->thumb_path);

} else {
           $this->_messages[] = $field['name' ] . 'did not upload please check and try again' ;
}

$this->thumb_path可能只包含沒有文件名的路徑。 沒有文件名:PHP應該如何命名文件?

嘗試放置相對路徑而不是將絕對路徑放在imagejpeg中,至少我是如何解決這個問題的。

$image_path=getcwd()."/your_images_directory/yourfile.jpg";

chmod您的目錄到775或任何提供您的要求。

此堆棧具有權限建議

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM