0
前阵子,我写了一个小工具函数,它INPATH和outpath中,打开两个和副本从一个到另一个使用的fread()和fwrite()。 allow_url_fopen已启用。PHP的fopen()函数不能得到URL,但卷曲会
嗯,我已经得到了我想要得到的内容的URL,而fopen()函数没有得到任何数据,但如果我用卷曲做同样的,它的工作原理。
相关网址为:http://www.deltagroup.com/Feeds/images.php?lid=116582497&id=1
的fopen版本:
$in = @fopen($inPath, "rb");
$out = @fopen($outPath, "wb");
if(!$in || !$out)
{
echo 0;
}
while($chunk = fread($in, 8192))
{
fwrite($out, $chunk, 8192);
}
fclose($in);
fclose($out);
if(file_exists($outPath))
{
echo 1;
}
else
{
echo 0;
}
卷曲版本:
$opt = "curl -o " . $outPath . " " . $inPath;
$res = `$opt`;
if(file_exists($outPath))
{
echo 1;
}
else
{
echo 0;
}
任何想法,为什么会发生这种情况?
即使使用PHP的卷曲
不要使用FOPEN的网址,这是一个小马车。您可以使用PHP内置的[卷曲功能(http://php.net/manual/en/book.curl.php) – aynber
是'allow_url_fopen'在php.ini中启用? http://php.net/manual/en/filesystem.configuration.php#ini.allow-url-fopen –
于allow_url_fopen是enbled-我可以从不同的网站就好了下载其他网址。 –