Search code examples
phpfilefwriteoverwrite

what contains file during overwriting content in php?


Assuming I want to overwrite a file with a big content. What will the others get if they pull content of file during overwriting ? First content? Nothing?


Solution

  • Nothing probably. I personally will tackle this situation with the method as such:

    1. Upload file as 'temporary.php'
    2. Delete the old file.
    3. Rename newly uploaded temporary.php to the old file.

    Process of renaming would have almost no latency, but if you want to be safe, probably you can have the viewer refresh the page once if the old file is missing.