Detecting that a file is done being copied
Posted: Tue May 12, 2009 7:44 am
I am trying to determine if a particular file is fully copied into a folder.
Let's say I have a Samba share called /incoming. I want to monitor the folder from a PHP script for new files and more importantly, I need to know when the file is fully copied into that folder.
I've tried fopen using mode r+, but that doesn't seem to work. I'm also looking at the filesize from fstat, but it appears that this info is set at file creation under Samba.
The motivation: I need to process the file in that folder once the file has been fully copied. I am dealing with gigabyte sized files so it can take several minutes for the file to fully copy into the folder. This has to be "user friendly" so easy solutions like creating a ".done" file in the same folder is out of the question. The end users will only see the /incoming folder and drop their files into it.
Any ideas on how I can solve this problem in PHP?
Let's say I have a Samba share called /incoming. I want to monitor the folder from a PHP script for new files and more importantly, I need to know when the file is fully copied into that folder.
I've tried fopen using mode r+, but that doesn't seem to work. I'm also looking at the filesize from fstat, but it appears that this info is set at file creation under Samba.
The motivation: I need to process the file in that folder once the file has been fully copied. I am dealing with gigabyte sized files so it can take several minutes for the file to fully copy into the folder. This has to be "user friendly" so easy solutions like creating a ".done" file in the same folder is out of the question. The end users will only see the /incoming folder and drop their files into it.
Any ideas on how I can solve this problem in PHP?