PHP lovers,
I have a script to do the followings:
(1) User upload file to a directory,example: /dir/jdoe
(2) At a certain (once a day), the script will go into the directory, if there are files, example, /dir/jdoe/fileAm /dir/jdoe/fileB, etc, the script will tar the files, give the tar file a new name , example: tarfile012302.tar. tarfile is from other variable, 012302 is from the system: date("mdy", time()).
This script works great as written. The intention was to run it ONCE a day and that is it. But now, the requirement has changed and the scripts may need to be run two times or three times or whatever times. The problem is that certainly the already tarred files will be overwritten with the same name.
I was thinking to add, for example, the minute and second to the file name so that file names will not be the same. Is there a better way to do this? The file names will be LONG!
While you are at it, how do I avoid to execute the tar operation when and if the file is being uploaded, i.e. still uploading.
I was thinking first to check the file size, then put the script to sleep (can it be done?) then check it again to see if the file size is still the same. If it is, then proceed to tar, else wait some more...
Any suggestions are welcome and appreciated.
Thanks