After you upload a script file to a Linux web hosting instance, dependent website features may fail. This can happen if the script file uses an incorrect text format, which prevents Linux text editors from correctly recognizing the line break characters in the file. This topic explains the cause and solution.
Symptoms
After editing a script file in DOS format on a Windows computer, you upload it to a Linux web hosting instance with an FTP client. You then find that the script's functions do not work on your website.
Cause
An incorrect file upload mode in your FTP client causes this issue. When a script file is uploaded in a text mode that preserves Windows-style line endings, a Linux host cannot correctly interpret them, leading to script execution failures. The key differences are:
-
Windows uses a carriage return and a line feed character (
\r\n) to mark the end of a line. In hexadecimal, this is0D 0A. -
Linux uses only a line feed character (
\n) to mark the end of a line. In hexadecimal, this is0A.
Solution
-
Open your FTP client.
This guide uses FileZilla version 3.66.5 as an example. Steps for other FTP clients may vary.
-
From the top menu bar, select .
-
In the Settings dialog box, from the left pane, select .
-
In the Default transfer type section, select Binary, and then click OK.
-
Upload the file again and verify that the script runs correctly.
If the issue persists, submit a ticket.