Jump to content

Downloading images


PhilipK

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.