Cross platform

PHP code stored in one line after uploaded to FTP – cross platform file transfer problem

Cross platformOne more problem solved today. PHP files were uploaded to our FTP server but we got a bunch of errors. That was strange because code worked correctly in local host. We figured out that our server deleted all “ End of Line” symbols – all code was placed in one line.

We checked our file with Notepad ++. Opened it and selected View->Show Symbol->Show End of Line:

Carriage return - cr
Carriage return - CR

As you can see in the picture all lines end with CR (carriage return) symbol. We changed it to LF (line feed) symbols with Notepad ++. Selected Edit->EOL Conversion->Unix Format:

Line feed - LF
Line feed - LF

After saving and uploading to FTP server it worked correctly – that solved our problem.

We found out that Pure-FTPd server deleted CR (carriage return) symbols. You can read more about this problem here.

If you are interested in different Line ending symbols (CR, LF, CRLF) in different operating systems you can find more information here.

This method did not solve your problem?

If this does not solve your problem try to transfer your files in BINARY mode. You can change transfer mode in Filezilla by selecting it in Transfer->Transfer type->Binary (by default it uses Auto – automatic detection):

Filezilla - binary transfer mode
Filezilla - binary transfer mode

It is better to try changing your “Line end” symbols to resolve this problem than to use BINARY mode. As I Know binary mode can damage your files – more information can be found here.

I hope this post will save somebody’s time :) If you have some questions just contact us – we will try to answer them ASAP! :)

One thought on “PHP code stored in one line after uploaded to FTP – cross platform file transfer problem

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>