我正在使用我的游戏网站,但为了让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