Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/286.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP中的FilePutContents_Php_Xml_Flash - Fatal编程技术网

PHP中的FilePutContents

PHP中的FilePutContents,php,xml,flash,Php,Xml,Flash,我无法将我的文件放入目录 $swfpath = "swf/"; file_put_contents($swfpath . $swf, file_get_contents($swf_url)); 它进入/example.swf而不是/swf/example.swf <?php include "mysql.php"; echo "you shouldn't be here"; $gt = $_POST["game_tag"]; connect() or die (mysql_err

我无法将我的文件放入目录

$swfpath = "swf/";
file_put_contents($swfpath . $swf, file_get_contents($swf_url));
它进入
/example.swf
而不是
/swf/example.swf

    <?php
include "mysql.php";
echo "you shouldn't be here";
$gt = $_POST["game_tag"];
connect() or die (mysql_error());
$pubId = 'censored';
if (!$gt)
    exit;
$data = file_get_contents("http://www.mochimedia.com/feeds/games/$pubId/$gt/?format=xml");
$response = new DOMDocument();
$response->loadXML($data);
$obj = $response->getElementsByTagName("entry")->item(0);
$sql = "INSERT INTO games (title, swfname, description, category, thumb) VALUES('";
$sql .= addslashes($obj->getElementsByTagName("title")->item(0)->nodeValue) . "','";
$swf_url = $obj->getElementsByTagName("link")->item(1)->getAttribute("href"); 
$swf = md5($sql);
$swfpath = "swf/";
file_put_contents($swfpath . $swf, file_get_contents($swf_url));
echo " URL = $swf_url";
$sql .= "$swf','";  //swfpath is the path of the directory where you store the swf files
$sql .= addslashes($obj->getElementsByTagName("description")->item(0)->nodeValue) . "','";
switch($obj->getElementsByTagName("category")->item(0)->nodeValue) {
    case "Action" : $sql .= "act','"; break;
    case "Shooting" : $sql .= "s','"; break;
    case "Shooter" : $sql .= "s','"; break;
    case "Classic" : $sql .= "c','"; break;
    case "Arcade" : $sql .= "a','"; break;
    default : $sql .= "m','"; break;
}
include "functions.php";
$thumbnail_url = $obj->getElementsByTagName("thumbnail")->item(0)->getAttribute("url");
$thumb = substr($thumbnail_url, -4, 4);
$thumbs = "".$gt."$thumb";
$thumbpath = "thumbs/";
file_put_contents($thumbpath . $thumbs, file_get_contents($thumbnail_url));
$sql .= "$thumbs');";  //thumbpath is the path of the directory where you store the thumb files
mysql_query("$sql") or die (mysql_error());
//insert the $sql to your database
?>
loadXML($data);
$obj=$response->getElementsByTagName(“条目”)->item(0);
$sql=“插入游戏(标题、swfname、描述、类别、拇指)值('”;
$sql.=addslashes($obj->getElementsByTagName(“title”)->item(0)->nodeValue)。“,”;
$swf_url=$obj->getElementsByTagName(“链接”)->item(1)->getAttribute(“href”);
$swf=md5($sql);
$swfpath=“swf/”;
文件内容($swfpath.$swf,文件内容($swf_url));
echo“URL=$swf_URL”;
$sql.=“$swf',”;//swfpath是存储swf文件的目录的路径
$sql.=addslashes($obj->getElementsByTagName(“description”)->item(0)->nodeValue)。“,”;
开关($obj->getElementsByTagName(“类别”)->item(0)->nodeValue){
案例“Action”:$sql.=“act',”break;
案例“射击”:$sql.=“s',”中断;
案例“Shooter”:$sql.=“s',”中断;
案例“Classic”:$sql.=“c',”中断;
案例“Arcade”:$sql.=“a',”中断;
默认值:$sql.=“m',”break;
}
包括“functions.php”;
$thumboil\u url=$obj->getElementsByTagName(“缩略图”)->item(0)->getAttribute(“url”);
$thumb=substr($thumbnail\u url,-4,4);
$thumbs=”“.$gt.“$thumb”;
$thumbpath=“thumbs/”;
文件内容($thumbpath.$thumbs,文件内容($thumbnail\u url));
$sql.=“$thumbs”);”//thumbpath是存储thumb文件的目录的路径
mysql_查询($sql)或die(mysql_error());
//将$sql插入数据库
?>

echo$swfpath时会得到什么$swf?它是您期望的完整文件路径吗?另外,您真的应该使用绝对路径而不是相对路径——如果您将脚本移动到另一个目录,它将中断。因此,在失败时,
$swf
是md5哈希吗?文件被放在当前目录中,而不是当前目录中的
swf/
目录中?