簡體   English   中英

imagick無法讀取文件

[英]imagick unable to read the file

我在文件中有以下php代碼:

$figloc = $_GET['figrl'];

try
{
$image = new Imagick($figloc);
$image->setImageFormat("jpg");
$image->setImageColorSpace(5);  
$image->writeImage("temp.jpg");
}
catch(Exception $e)
{
 echo $e->getMessage();
}

和這樣的jQuery腳本:

<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function() {
    figurelocation='temp.jpg';
    var fightmlstring='<img src=\"'+figurelocation+'\">';
    $('.figuredisplay').append(fightmlstring);
});

Figuredisplay是一個div元素。 $ figloc值是磁盤上映像的絕對地址,例如“ /home/abc/def/ghi/jkl.tiff”。 從適當的鏈接打開該php文件時,顯示錯誤消息“ imagick無法打開文件/home/abc/def/ghi/jkl.tiff”。 絕對地址會引起問題嗎?

另外,當我將特定的tiff文件復制到目錄中時,要查看絕對地址是否有問題,imagick會着手讀取該文件,但無法創建temp.jpg。

unable to open image `/var/www/temp.jpg @ error/blob.c/OpenBlob/2489 

誰能指出我做錯了什么?

好的,我知道了問題所在。 這真是一個愚蠢的。 我寫這篇文章是為了讓其他面臨相同問題的人受益。

代替

$image = new Imagick($figloc);

寫:

$abc= substr ( $figloc , 1, strlen($figloc)-2);
$image = new Imagick($figloc);

因此,figloc字符串中的單引號被刪除。 真傻:-)

暫無
暫無

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

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