Page 1 of 1

script that would run when a file changes?

Posted: Thu Dec 14, 2006 6:47 pm
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

Posted: Fri Dec 15, 2006 2:12 am
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)?

Posted: Fri Dec 15, 2006 2:28 am
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.

Posted: Fri Dec 15, 2006 4:08 am
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

Posted: Fri Dec 15, 2006 4:33 am
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?

Posted: Fri Dec 15, 2006 4:48 am
by Shendemiar
Cron