PhilipK Posted May 12, 2011 Share Posted May 12, 2011 Hello I'm trying to make a php script that when run updates an image folder based on a photobucket feed. Here is my code so far. <?php function download_feed($path) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $path); curl_setopt($ch, CURLOPT_FAILONERROR, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 15); $retValue = curl_exec($ch); curl_close($ch); return $retValue; } $sXML = download_feed('http://feed242.photobucket.com/albums/ff185/xivanari/account.rss'); $oXML = new SimpleXMLElement($sXML); foreach($oXML-> channel->item as $oDocuments) { $fileName = $oDocuments->title; $fileTmpLoc = $oDocuments->link; if(!file_exists("album1/".$fileName."/")) { if(!mkdir("album1/".$fileName)) $upload_location = "album1/".$fileName; $moveResult = move_uploaded_file($fileTmpLoc, $upload_location); } } ?> Link to comment https://forums.phpfreaks.com/topic/236264-downloading-images/ Share on other sites More sharing options...
fugix Posted May 12, 2011 Share Posted May 12, 2011 what is your question? Link to comment https://forums.phpfreaks.com/topic/236264-downloading-images/#findComment-1214710 Share on other sites More sharing options...
PhilipK Posted May 12, 2011 Author Share Posted May 12, 2011 Question is how can I edit the following code to make it upload an image to a folder on the server? Or where did I go wrong? $fileName = $oDocuments->title; $fileTmpLoc = $oDocuments->link; if(!file_exists("album1/".$fileName."/")) { if(!mkdir("album1/".$fileName)) $upload_location = "album1/".$fileName; $moveResult = move_uploaded_file($fileTmpLoc, $upload_location); Link to comment https://forums.phpfreaks.com/topic/236264-downloading-images/#findComment-1214724 Share on other sites More sharing options...
PhilipK Posted May 12, 2011 Author Share Posted May 12, 2011 I guess my question is how do I use PHP to download all the images from an rss feed? The code needs to skip over images which have been downloaded in the past. Link to comment https://forums.phpfreaks.com/topic/236264-downloading-images/#findComment-1214727 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.