views:

451

answers:

1

I tried uploading files to my server

my.php (normal local file)

<?php
$box_title= "SEARCH ME"
?>

After uploading via FileZilla FTP Client (remote server file)

// SOMETIMES ABOVE FILE BECOMES
<?php$box_title= "SEARCH ME"?>

// OR SOMETIMES LIKE THIS
<?php

$box_title= "SEARCH ME"

?>

I suspect this is a server related issue, but not sure. Can anyone explain this problem with solution

Thanks

+1  A: 

An above comment already suggested looking at ASCII/binary mode. It's a weird property of FTP that files can be treated as ASCII text (in which case the FTP transmission will automatically change the encoding of line endings to fit the one used by the target machine) or binary (in which case they'll be transferred without any changes).

The mutilation you quoted in your question is probably not half as bad as it looks; some editors actually do not display UNIX-style line ending encoding (which is what FTP in ASCII mode probably put into your files) even though it's there.

The different encodings for line endings are a constant source of grief in portable computing stuff... in this case the best thing I can recommend is for you to try out if it works the way you do it now, and if it doesn't, try forcing your FTP client's transfer mode to a different setting.

Jan Krüger
I tried with "Binary mode" and it worked. So should i keep it as binary mode for future files (image/file) uploading?
Ish Kumar
It's pretty much up to you. If the resulting files work fine, by all means stick with binary mode. Sometimes you get confusing results with binary mode if the server expects a different line ending encoding than your files have, but you probably don't need to worry about that until it happens.
Jan Krüger