Newb:: Remote Last Modification Time.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
spidie
Forum Newbie
Posts: 3
Joined: Thu Jul 31, 2003 8:36 pm

Newb:: Remote Last Modification Time.

Post 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.
McGruff
DevNet Master
Posts: 2893
Joined: Thu Jan 30, 2003 8:26 pm
Location: Glasgow, Scotland

Post 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.
spidie
Forum Newbie
Posts: 3
Joined: Thu Jul 31, 2003 8:36 pm

Post by spidie »

filemtime() and fstat() don't work with REMOTE files..
McGruff
DevNet Master
Posts: 2893
Joined: Thu Jan 30, 2003 8:26 pm
Location: Glasgow, Scotland

Post by McGruff »

:oops: oops I should read posts more carefully.
User avatar
DuFF
Forum Contributor
Posts: 495
Joined: Tue Jun 24, 2003 7:49 pm
Location: USA

Post 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.
spidie
Forum Newbie
Posts: 3
Joined: Thu Jul 31, 2003 8:36 pm

Post 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.
User avatar
DuFF
Forum Contributor
Posts: 495
Joined: Tue Jun 24, 2003 7:49 pm
Location: USA

Post 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.
Post Reply