我正在使用我的遊戲網站,但爲了讓Facebook API正常工作,我必須製作一個新的腳本,可以根據遊戲的ID。這是這個腳本試圖做的,但我得到這個錯誤。從數據庫中抓取圖片,然後在url中寫入文件
Warning: readfile(localhost/thumbs/6c9e40d35e8cf07e.png) [function.readfile]: failed to open stream: No such file or directory in B:\home\home\thumb.php on line 22
我想知道你們中的任何一位能否幫助我。
<?php
require_once "functions.php";
if(!isset($_REQUEST['t'])){
die("No ID Defined");
}
$t = $_REQUEST['t'];
$t = intval($t);
connect();
$fetch = fetchdata("select * from `games` where id = $t");
$thumb = $fetch{'thumb'};
$file = "/thumbs/$thumb";
$filename = basename($file);
$file_extension = strtolower(substr(strrchr($filename,"."),1));
switch($file_extension) {
case "gif": $ctype="image/gif"; break;
case "png": $ctype="image/png"; break;
case "jpeg":
case "jpg": $ctype="image/jpg"; break;
default:
}
header($ctype);
readfile($_SERVER['HTTP_HOST'].'/thumbs/'.$thumb);
?>
首先嚐試'readfile('http://'。$ _SERVER ['HTTP_HOST']。'/ thumbs /'。拇指);'看看是否修復它。您需要使用圖像的完整路徑,或者在localhost前面指定「http://」。 – drew010 2012-04-10 22:04:24