HTML文件中有这么多脚本标记源... 例如:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="js/superfish-1.4.8/js/supersubs.js"></script>
<script src="js/tweet/jquery.tweet.js" ></script>
我想要做的是......通过以下代码制作与src文件相同的文件夹结构...
<?php
$srcCode = $_POST['doc'];
$url=$_POST['Url'];
$url_path=$url;
foreach($html->find('script') as $script)
{
$scriptPath=$script->src;
$path="";
$js = explode("/", $scriptPath);
for ($i=0;$i<(count($js)-1);$i++)
{
$path .= $js[$i] . "/";
if(!file_exists('folder/'.$path))
{
mkdir('folder/'.$path, 0777, true); //line 15
}
}
$jsName = end($js);
file_put_contents('folder/'.$path.$jsName,file_get_contents($url_path.$scriptPath)); //line 19
}
?>
它给我警告:
Warning: mkdir() [function.mkdir]: in line 15
Warning: file_get_contents(http://localhost/rock/http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.1 403 Forbidden in C:\xampp\htdocs\core.php on line 19
Warning: file_put_contents(../include/http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js) [function.file-put-contents]: failed to open stream: Invalid argument in C:\xampp\htdocs\core.php on line 19
这里的问题是这些警告和另一个问题是我怎么能避免那个绝对的网址不创建文件夹..... 请帮助我给你宝贵的时间回答......:)