script that would run when a file changes?

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
dimovi
Forum Newbie
Posts: 7
Joined: Wed Nov 22, 2006 11:29 pm
Location: Austin, TX, USA
Contact:

script that would run when a file changes?

Post by dimovi »

Ive got PHP 5.1.4 on Apache 2.0 Handler and Win XP OS.

I don't know if that is possible or how to go about doing it, but I need a script that would call a function as soon as a file is added or deleted anywhere in a specific directory (resize images in a photoalbum).

thanks
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

dimovi wrote:as soon as a file is added or deleted anywhere in a specific directory (resize images in a photoalbum).
How is this file added or deleted (ie who or what might be able to detect the change)?
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

build an array of the current files in the directory, store it somewhere. every x seconds or minutes build an array of the directory and compare it to the stored array. then by comparing the arrays you can tell if any files are missing or if new ones are added.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
dimovi
Forum Newbie
Posts: 7
Joined: Wed Nov 22, 2006 11:29 pm
Location: Austin, TX, USA
Contact:

Post by dimovi »

volka wrote:How is this file added or deleted (ie who or what might be able to detect the change)?
win explorer or ftp client
dimovi
Forum Newbie
Posts: 7
Joined: Wed Nov 22, 2006 11:29 pm
Location: Austin, TX, USA
Contact:

Post by dimovi »

scottayy wrote:build an array of the current files in the directory, store it somewhere. every x seconds or minutes build an array of the directory and compare it to the stored array. then by comparing the arrays you can tell if any files are missing or if new ones are added.
I was thinking of something more like a trap routine, but I obviously don't know if there is anything even close to that.
I thought of doing what you suggested, but I don't know how to execute that code. How do I do that without using a browser?
Shendemiar
Forum Contributor
Posts: 404
Joined: Thu Jan 08, 2004 8:28 am

Post by Shendemiar »

Cron
Post Reply