Curl download image only if not older than 2 days
Posted
by
mark
on Stack Overflow
See other posts from Stack Overflow
or by mark
Published on 2010-12-22T09:05:33Z
Indexed on
2010/12/28
14:54 UTC
Read the original article
Hit count: 170
curl
I want to download a image from a remote server only if it is not older than 2 days. I have the constructing as below now. Is this right? I want to now the last_modified data first before downloading.
$ch = curl_init($file_source); // the file we are downloading curl_setopt($ch, CURLOPT_TIMEOUT, 20); curl_setopt($ch, CURLOPT_FILE, $wh); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_FILETIME, true); curl_exec($ch); $headers = curl_getinfo($ch); $last_modified = $headers['filetime'];
if ($last_modified != -1) { // unknown echo date("Y-m-d", $last_modified); //etc }
curl_close($ch); fclose($wh);
© Stack Overflow or respective owner