Page 1 of 1

Newb:: Remote Last Modification Time.

Posted: Thu Jul 31, 2003 8:36 pm
by spidie
I'm a relative newb. I was wondering if there is a function that will find the last modified time of a remote file such as a .gif or .jpg.

If there is no function could someone help with the coding, please.

Thanks in advance.

Posted: Thu Jul 31, 2003 9:02 pm
by McGruff
filemtime() & fstat() (latter not supported on Windows)

Sounds like you don't have a php manual: I'd recommend downloading the version with user comments from php.net.

Posted: Thu Jul 31, 2003 9:21 pm
by spidie
filemtime() and fstat() don't work with REMOTE files..

Posted: Thu Jul 31, 2003 9:24 pm
by McGruff
:oops: oops I should read posts more carefully.

Posted: Thu Jul 31, 2003 9:29 pm
by DuFF
By remote, do you mean on a users computer? How would you accomplish this considering that jpg's and gif's would never be stored on the same place on every computer? The only thing that comes to mind is fopen() but I have no idea if that would work for what you are thinking of.

Posted: Thu Jul 31, 2003 9:33 pm
by spidie
I'll explain more..

if someone were to give me a URL of an image on their hosting, i would put that into a database. I would then run a script that would run through all the images and find out the last time they were modified and post them in order they were modified.

If that helps.

Posted: Thu Jul 31, 2003 9:55 pm
by DuFF
**EDIT**
Look at the user notes below filemtime, there is a post that shows an example of how to find the last modified time for a remote file.
**END EDIT**

Code: Select all

<?php
$url = "http://www.example.com/";
$filename = fopen ("$url", "r");
if ($filename)  {
$lastmodified = filemtime($filename);
echo $lastmodified;
}
else  {
die ("Could not open the file");
}
?>
Try this out, see if it works. I have not tested it because I just got a new comp and don't have my FTP program yet. I checked out fopen() and it said it could open URL's, the "r" next to opens the $url for reading.