NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
uploaded files have extra newlines


Joined: 26 Jan 2009
Posts: 12
Reply with quote
I can't find anything on this, and I've googled for it and searched these forums repeatedly.

When I upload a file from my windows machine to my linux server, everything is OK. I am using winSCP.
when I upload it with phpED, it inserts newlines after every line. This wrecks my ajax stuff.

Anyone know what could be happening?
View user's profileFind all posts by pineappleclockSend private messageVisit poster's website
Site Admin

Joined: 13 Jul 2003
Posts: 8344
Reply with quote
It was discussed many times there.

PhpED does never insert any newlines when it performs file transfers. Most probably your files are in Windows format (0x13, 0x10 as line ending) and you've turned on ASCII transfer mode. In this case some ftp servers don't recognize the file format. They replace both 0x13 and 0x10 with 0x10. As a result you see the newlines doubled.

I'd highly recommend to select binary transfer mode in the account settings.

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 26 Jan 2009
Posts: 12
Reply with quote
dmitri wrote:
It was discussed many times there.
I'd highly recommend to select binary transfer mode in the account settings.


I can't find in PHPed 5.5 where I can enable binary/ASCII transfer mode. Searching the help files produced nothing. There's no options in the account settings.

I did some packet capturing on PHPed's FTP client, and it looks like it sets the mode to Binary (I) mode for transfers, which skips win/unix CRLF conversion at the FTP server, but I guess it would depend on the server. Both of the FTP clients I tested (winSCP, Filezilla) transferred the same file to the same server as ASCII.

There should really be a way to force PhpED to use ASCII mode... is there?

Code:



--- PhpED 5.5.5519 ---

USER [removed]
331 User [removed] OK. Password required
PASS [removed]
230-User [removed] has group access to:  [removed] 
230 OK. Current restricted directory is /
TYPE I
200 TYPE is now 8-bit binary
SYST
215 UNIX Type: L8
PWD
257 "/" is your current location
CWD /public_html/
250 OK. Current directory is /public_html
PWD
257 "/public_html" is your current location
PWD
257 "/public_html" is your current location
CWD /public_html/[removed]/
250 OK. Current directory is /public_html/[removed]
CWD /public_html
250 OK. Current directory is /public_html
PORT 192,168,0,117,8,65
200 PORT command successful
STOR /public_html/[removed]/__test.php
150 Connecting to port 37827
226-File successfully transferred
226 0.066 seconds (measured here), 38.52 Kbytes per second


--- WinSCP 4.1.3 ---
TYPE A
200 TYPE is now ASCII
PORT 192,168,0,117,8,56
200 PORT command successful
STOR __test.php
150 Connecting to port 37744
226-File successfully transferred
226 0.051 seconds (measured here), 48.68 Kbytes per second
TYPE A
200 TYPE is now ASCII
PORT 192,168,0,117,8,57
200 PORT command successful
LIST -a
150 Connecting to port 37745
226-Options: -a -l 226 38 matches total

--- Filezilla 3.2.2 ---
TYPE A
200 TYPE is now ASCII
PORT 192,168,0,117,14,187
200 PORT command successful
STOR __test.php
150 Connecting to port 44690
226-File successfully transferred
226 0.026 seconds (measured here), 94.28 Kbytes per second
View user's profileFind all posts by pineappleclockSend private messageVisit poster's website
Site Admin

Joined: 13 Jul 2003
Posts: 8344
Reply with quote
If your FTP server adds extra CR-LF even when transfer mode is set to binary, it's definitely broken and I'd highly recommend you to switch to another server like ProFTPD, vsftpd, or wuftpd as they all are known to work fine, at least in their recent versions.

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 26 Jan 2009
Posts: 12
Reply with quote
That is a non-solution. I work with lots of different FTP servers and am not able to change settings on them much less install different FTP daemons.

ASCII is the default transfer mode as required by RFC 959 (3.1.1.1). The ASCII transfer mode converts Windows' CRLF to UNIX's LF characters. It does change the file contents, but this is a feature and desired.

PHPed needs the ability to transfer text files in ASCII mode, or set transfer mode by extension, like other FTP clients.
View user's profileFind all posts by pineappleclockSend private messageVisit poster's website
Site Admin

Joined: 13 Jul 2003
Posts: 8344
Reply with quote
You right, ASCII is the default mode but we do not use it just because in this mode the file content IS changed and it is NOT what we want. We want the file to remain UNCHANGED, WITHOUT any extra line endings. That's why we always use BINARY mode.
If your server CHANGES the files in this mode, just don't use it our use only UNIX file endings.
PhpED does recognize the line endings:
0x0D, 0x0A - as Windows
0x0A - as Unix
0x0D - as Mac

all other possible combinations may cause unexpected results.
Please DO CHECK the file content on the server before downloading it. If it is with BROKEN line endings, don't blame at us Smile

Quote:
The ASCII transfer mode converts Windows' CRLF to UNIX's LF characters. It does change the file contents, but this is a feature and desired.


This is a good theory. In practice many old Unix ftp servers does not handle Windows line endings at all Smile or corrupt them.

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website
uploaded files have extra newlines
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 5 Hours  
Page 1 of 1  

  
  
 Reply to topic