0

I sometimes upload new files to my PHP website via FTP. When I do this, users sometimes get "Unexpected end of file" errors when they do something on the website related to these files in the few seconds that the file is uploading.

Using FTP is the easiest option for me from a workflow perspective sometimes. Should I just avoid it altogether to avoid these errors? Or is there something I can do (eg change PHP or server settings) to avoid these errors (eg delay server response until the file upload is completed)?

1 Answers1

0

To avoid this problem, you can use rsync instead. By default, rsync first copies the file to the new host, then moves into the location of the old file after the upload is complete. So you don't get the partially transferred file problem. For details see --inplace in man rsync.

You can also do this manually by first uploading the files to another directory, then moving them once the upload is complete.

Andrew Schulman
  • 8,811
  • 21
  • 32
  • 47