Reputation: 6367
I have a script that creates a file using fwrite
and right after creating it it sends and email with this file anexed.
When I run this script I get an error "File does no exists". When I run the script again it all works.
So I guess that it tries to send the file to fast after creating it and the server maybe needs a few more ms before being able to send it.
Does anyone know this problem? Any solutions?
Upvotes: 0
Views: 78
Reputation: 5041
Delays should not be necessary; it is possible your script does not close the file, but PHP and other script languages will auto close open file handles at the end of execution, which means that the file will exist for the second run.
Upvotes: 1
Reputation: 1055
Try sleep(1)
before attaching the file, this will cause PHP to wait 1 second before trying to access the file which should be plenty of time for it to be created. This should tell you if the file creation speed is the problem or not.
Upvotes: 0