-1
我的劇本相當多的作品,但是當我運行一個for循環失敗,在視圖中:安全圖像失敗 - 笨
<?php foreach($pics as $index=>$pic){?>
<td class='Pictures'>
<center>
<?php
$piece = explode('/',$pic["ThumbImg"]);
$string = $piece[5];
?>
<img src='<?php echo base_url(); ?>index.php/Controller/getImage/<?php echo $string; ?>/1' width="100px">
</a>
Controller類 - 獲取圖像功能:
//function to protect images from being accessed directly by obfuscating the URL
function getImage($img_id,$type){
if($this->members->logged_in()){
//code to authenticate user goes here then...
//code to decide which type of file it is/thumb/full size image
if($type==1)
{
$url = $this->data['base_url'].'system/application/images/pic/thumbs/';
}else if($type==0){
$url = $this->data['base_url'].'system/application/images/pic/';
}
$filepath = $url.$img_id;
//send image to web browser.
header("Content-type: image/jpeg");
//get path
$img_handle = imagecreatefromjpeg($filepath) or die("");
//create and send
ImageJpeg($img_handle);
}
我懷疑這可能是由於標題被重新發送,如果是的話,我該如何解決這個問題。
乾杯
解決了這一問題 - 用「盜鏈」
所以你的代碼在不在循環中工作?你有什麼錯誤嗎?你怎麼知道它不起作用 – 2012-08-10 13:39:53
基本上Web服務器卡住了。當它最終執行頁面時,不會獲取圖像。 – thejoker 2012-08-10 14:11:03