保存圖像我有這個URL如何下載和鏈接
'http://2.bp.blogspot.com/-LBbpkomI7JQ/VnLmeFZANgI/AAAAAAAAWhc/MsdZjtxN0HQ/s0-Ic42/RCO001.jpg '
我試圖做一些搜索,這樣做,
$file = fopen("C:\Users\Alex\Desktop\script.txt", "r");
$links = array();
while (!feof($file)) {
$links[] = fgets($file);
}
fclose($file);
foreach($links as $num => $link)
{
echo "'".$link."'";
save_image("'".$link."'","'".$num."'".".jpg");
}
var_dump($links);
function save_image($inPath,$outPath)
{ //Download images from remote server
$in= fopen($inPath, "rb");
$out= fopen($outPath, "wb");
while ($chunk = fread($in,8192))
{
fwrite($out, $chunk, 8192);
}
fclose($in);
fclose($out);
}
所有URL都在我的script.txt文件,所以我我將它們存儲在一個數組中然後調用每個url一個接一個,但它說
failed to open stream: Invalid argument
任何錯過或錯誤?
這是了! – Alex