upload to temporary name to avoid script errors
|Reported by:||tutils||Owned by:|
|Component version:||Operating system type:|
|Operating system version:|
Description (last modified by )
Many sites use PHP or other scripting languages. Those scripts cannot be accessed by visitors of the site until they are fully uploaded to the server. During upload and until they are fully uploaded, they produce a 500 internal server error message (or white page, depending on the server configuration).
This is especially relevant when uploading and overwriting a large PHP file on the server, for example "functions.php", which disables the entire site during the upload, and can lead to unexpected results and even lost data in certain cases, for example when a visitor just submits a form.
My suggestion is to upload the file using a temporary name (instead of overwriting), and when the upload completes, rename back to the original name. On linux renaming over an existing FTP file is possible, but on Windows (or SFTP) it is not. So if the renaming fails, it should delete the original file, and then rename again. The downtime would still be much faster than with normal overwriting of the file.