|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2003-08-29 13:23 UTC] phpbugs at brianmertens dot com
Description: ------------ This seems to be the same problem as 19036 (Closed) and 18162 (No Feedback). Since neither is still open, I am filing a new report. I will provide any feedback required. I can test snaps if they are compiled for Windows. Simply put, if I connect to a Unix (AIX 4.3) server and use ftp_get() to fetch a text file to a Windows machine with the FTP_ASCII option, the newlines are NOT converted to CR/LF pairs. ftp_get( $conn, "file.txt", "file.txt", FTP_ASCII ); I have reproduced this with 4.2.x, 4.3.2 & 4.3.3. (Note that ftp_systype() returns "UNKNOWN".) Reproduce code: --------------- $conn = ftp_connect( "server" ); ftp_login( $conn, "username", "password" ); ftp_get( $conn, "file.txt", "file.txt", FTP_ASCII ); Expected result: ---------------- Lines terminated with CR/LF pairs (x0D x0A). Actual result: -------------- Lines terminated with single x0A chars. PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 18:00:01 2025 UTC |
This works as workaround: <?php $conn = ftp_connect( "server" ); ftp_login( $conn, "user", "pass" ); $fp = fopen('localfile.txt', 'wt'); ftp_fget( $conn, $fp, 'remotefile.txt", FTP_BINARY ); ?>I think this problem has not fixed yet. I am using php4.3.4 and it got worth replacing \n to \r. this code must be put in ftp_get function to fix this problem: lastch = 0; while ((rcvd = my_recv(ftp, data->fd, data->buf, FTP_BUFSIZE))) { if (type == FTPTYPE_ASCII) { for (ptr = data->buf; rcvd; rcvd--, ptr++) { if ( *ptr == '\n') php_stream_putc(outstream, '\r'); if (lastch == '\r' && *ptr != '\n') php_stream_write(outstream, '\r\n', 2); if (*ptr != '\r') php_stream_putc(outstream, *ptr); lastch = *ptr; } } } if (type == FTPTYPE_ASCII && lastch == '\r') php_stream_write(outstream, '\r\n', 2);