Can PHP process a file automatically?

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
paolone
Forum Commoner
Posts: 37
Joined: Tue Jun 11, 2002 10:18 am

Can PHP process a file automatically?

Post by paolone »

Hi, i have a script that process a file that is sent from a macro to a directory.

then from the server i open the web interface, where i open the file and process it.

I'm wondering if there is a way with PHP to run the script when the file arrive to the directory automatically. Of course after the file is read it must be deleted...

Thanks for your hints...
malcolmboston
DevNet Resident
Posts: 1826
Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK

Re: Can PHP process a file automatically?

Post by malcolmboston »

paolone wrote: I'm wondering if there is a way with PHP to run the script when the file arrive to the directory automatically. Of course after the file is read it must be deleted...

Thanks for your hints...
Doing something like this, imo anyway, would require a real-time directory analyzer at OS level, which PHP simply doesnt have access to.

PHP's execution is execution-based, meaning the code only parses when the file has been executed (loaded into browser etc) something like this would require PHP to have real-time actions which it simply doesnt.

Something like C is perfect for this
paolone
Forum Commoner
Posts: 37
Joined: Tue Jun 11, 2002 10:18 am

Post by paolone »

Ok, thank you...

But if i got it well, i could run a command on the server where the file is hosted and run the script to process the file, right?

Doing so, i will have a command running that will save a file on the directory, and then another that will run after this, to execute the file (let's say) 'monitoring.php'.This will be opened in the browser window and will be executed...

But how can i scan a directory to retrive the file name?
Using 'file_exits', and then?
User avatar
n00b Saibot
DevNet Resident
Posts: 1452
Joined: Fri Dec 24, 2004 2:59 am
Location: Lucknow, UP, India
Contact:

Post by n00b Saibot »

Post Reply