I don't want an other application to read the files while this php app upload/overwrites files to the remote server
Hi,
There is no such thing as locking/unlocking files with ftp. Maybe some server can implement this kind of thing, but it should be non-standard. So, PHP is not managing this kind of thing.
By the way, depending your case, you can upload your file into a temporary directory and then rename it. Renaming is an atomic procedure, and it can be the right way to avoid your clients to download an non-finished upload file.
As Patrick Marie correctly says, files are not locked during an FTP transaction. You can easily try out yourself: Start uploading a big file, and request it in your browser a few seconds later. You will get a truncated version of the file.
If it doesn't conflict with anything else, you could rename the file (e.g. append a .lock
extension or prepend a .
, which will hide it on Unix/Linux systems in some constellations) during your transaction, do your stuff, and rename it back when it's done.
One danger in this is that if your script gets aborted, the renamed file remains renamed and/or hidden, which can be a problem.