2017-06-02 106 views
-2

昨天我得到了一個輸出imagejpg()(雖然不可讀的字符,因爲我沒有設置標題),但今天沒有。我改變的唯一的事情是在服務器上啓用特殊權限。任何想法還有什麼可能影響它?以下代碼的輸出是:Imagejpeg返回false但文件存在

The file exists 
Imagejpeg: FALSE 
Imagejpeg: FALSE 
The file is writable 

的輸出是相同的,如果$filename = $URL

代碼:

clearstatcache(); 
$filename = $_SERVER['DOCUMENT_ROOT'] . "/wordpress/wp-content/themes/mytheme/images/thumbnails/sb1778/1.jpg"; 
$URL = get_template_directory_uri() . "/images/thumbnails/sb1778/1.jpg"; 



if (file_exists($filename)) { 
    echo "<BR> The file exists"; 
} else { 
    echo "<BR> The file does NOT exist"; 
} 

if((imagejpeg($filename)) === true) 
{echo "<BR> Imagejpeg: TRUE";} 
else {echo "<BR> Imagejpeg: FALSE";} 
imagejpeg($filename); 

if((imagejpeg($URL)) === true) 
{echo "<BR> Imagejpeg: TRUE";} 
else {echo "<BR> Imagejpeg: FALSE";} 
imagejpeg($URL); 




if (is_writable($filename)) { 
    echo '<BR> The file is writable'; 
} else { echo '<BR> The file is NOT writable'; 
} 
+0

你應該使用手動啓動,爲'imagejpeg第一個參數()'是不是串。 – jeroen

+0

您說的手冊?有趣。謝謝!! – Atrag

回答

0

的圖像需要經過Imagescreatefromjpeg功能第一:

$filename = imagecreatefromjpeg($_SERVER['DOCUMENT_ROOT'] . "/wordpress/wp-content/themes/mytheme/images/thumbnails/sb1778/1.jpg"); 
相關問題