我有這個網址www.example.com/1.png
。我想運行一個循環,像這樣:如果圖片存在,從url下載圖片
for ($i=0; $i<=10; $i++){
$url = 'www.example.com/'.$i.'.png';
}
現在我有10倍的網址。可以說10個網址中有7個是圖像,其他3個網站不可用。我想從每個URL下載圖像,如果URL不存在,那麼它不會下載任何東西。
繼承人的同樣的事情,但解釋更basicly我想:
www.example.com/1.png --- url exists, so i download the image and save it in my folder.
www.example.com/2.png --- url exists, so i download the image and save it in my folder.
www.example.com/3.png --- url doesnt exist, so i dont download anything
www.example.com/4.png --- url exists, so i download the image and save it in my folder.
www.example.com/5.png --- url exists, so i download the image and save it in my folder.
www.example.com/6.png --- url exists, so i download the image and save it in my folder.
www.example.com/7.png --- url doesnt exist, so i dont download anything
www.example.com/8.png --- url exists, so i download the image and save it in my folder.
www.example.com/9.png --- url exists, so i download the image and save it in my folder.
www.example.com/10.png --- url doesnt exist, so i dont download anything
對不起,我的英語不好,有什麼建議,我怎麼能解決這個問題?
問題在哪裏?你試過了什麼?如果您不知道保存文件的功能,您可以使用file_get_content()和file_put_content(),請在php手冊 – aleation 2013-03-19 13:18:27
中查找它們,感謝檢查file_get_content()和file_put_content() – Edgar 2013-03-19 13:19:15
只需嘗試下載URL。如果你有圖像,耶,否則不。 – deceze 2013-03-19 13:20:59