Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3601332
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T20:36:32+00:00 2026-05-18T20:36:32+00:00

I want to download an image from a remote server only if it is

  • 0

I want to download an image from a remote server only if it is not older than two days.

Is the code I’m running bellow correct? I want to know the last_modified data 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);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T20:36:33+00:00Added an answer on May 18, 2026 at 8:36 pm
    $file_source = 'http://www.google.com/images/nav_logo29.png';
    $ch = curl_init($file_source);
    curl_setopt($ch, CURLOPT_TIMEOUT, 20);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    
    curl_setopt($ch, CURLOPT_FILETIME, true);
    curl_setopt($ch, CURLOPT_HEADER, true);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, false); <-- don't download first
    curl_exec($ch);
    $headers = curl_getinfo($ch);
    $last_modified = $headers['filetime'];
    
    if ($last_modified != -1)
    {
      if ($last_modified>time()-86400*2) <-- not older than 2 days
      {
        $ch2 = curl_init($file_source);
        $wh  = fopen('YOUR_PATH, 'w');
        curl_setopt($ch2, CURLOPT_FILE, $wh);
        curl_exec($ch2);
        curl_close($ch2);
        fclose($wh);
      }
    }
    curl_close($ch);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to download an image from a remote server only if it is
I want to Download An image from a remote server. But each time I
I want to download image from server and display them into a layout EXAMPLE
I want to download image from the path. This is my code: String urlString
I want to download image from url and store in sdcard's folder. If folder
I want to force the download of an image. I have found this code:
what I want: Download a webpage from a server > Save content in a
I want to download a single frame of a video file from a server
I want to download an image from the 'net and set it as the
i want to display a image after downloading that image from a web-server i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.