I have a cron script that compresses images. It basically iterates over folders and then compresses the files in the folder. My problem is that some images are getting processed halfway. My theory is that users are uploading a image, and before the image has finished uploading the file, the compressor tries to compress the file. Thus compressing a half-uploaded image, and resulting in half an image being displayed.
- Is there a way in PHP to confirm that a file has finished uploading? So that I can only do the compression once i know the file has been fully written?
- Or alternatively, is there a way to check if a file is being used by another process?
- Or alternatively, would it be reliable enough to look at when the file was "written to disk" and not process it until 10 minutes has gone by?