PHP download file while reading
I have two PHP services. One that let other users to download a file. Another that fetch every some time an updated version of that file. Now I am implementing it through flock(). I thought of improving it by usin开发者_开发技巧g link() - I mean downloading the file and then link to the new downloaded file. But, there is a problem with this way because you cannot link() a file that is already is being link.
Any ideas?
Download the new file to a temporary filename and then move it over to the real filename. No need to deal with links or locks. Your filesystem normally knows what it does.
Just add some error checking and deal with errors.
精彩评论