automatically add txt files into server folders

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
aneuryzma
Forum Contributor
Posts: 106
Joined: Sat May 17, 2008 7:03 am

automatically add txt files into server folders

Post by aneuryzma »

hi,

I would like to know if it is possible to automatically create an empty txt file on the server when a new picture is added.

For example:

picture1.jpg is added (through ftp, or through back-end of my content mangament system)

the server "produces" the picture1.txt file

Similarly, whwn you remove picture1.jpg, also the picture1.txt file is gone.

thanks
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: automatically add txt files into server folders

Post by VladSun »

Yes, it's possible.
There are 10 types of people in this world, those who understand binary and those who don't
aneuryzma
Forum Contributor
Posts: 106
Joined: Sat May 17, 2008 7:03 am

Re: automatically add txt files into server folders

Post by aneuryzma »

thanks!

How can I do it ?
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: automatically add txt files into server folders

Post by VladSun »

There are 10 types of people in this world, those who understand binary and those who don't
aneuryzma
Forum Contributor
Posts: 106
Joined: Sat May 17, 2008 7:03 am

Re: automatically add txt files into server folders

Post by aneuryzma »

thanks, one more question:

how can I detect when a file is uploaded or added to a specific folder ?

I need it working if I use ftp or back-end as well.

thanks
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: automatically add txt files into server folders

Post by VladSun »

When the file is uploaded via HTTP file upload form you should create (using the same PHP script) the TXT file at the time file has been uploaded successfully.
FTP uploads ... Some of the FTP servers have abilities to run user defined scripts on file upload/download.
Another approach would be to create a cron job (scheduled task) which periodically checks for new files.
There are 10 types of people in this world, those who understand binary and those who don't
Post Reply