#41056 [NEW]: FTP function converts text file into Windows Text file always in ASCII mode.

From: Date: Wed, 11 Apr 2007 18:19:43 +0000
Subject: #41056 [NEW]: FTP function converts text file into Windows Text file always in ASCII mode.
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-111368@lists.php.net to get a copy of this message
From: daniel at supercomm dot com Operating system: Linux PHP version: 5.2.1 PHP Bug Type: FTP related Bug description: FTP function converts text file into Windows Text file always in ASCII mode. Description: ------------ FTP function converts text file into Windows Text file always while in ASCII mode. ftp_fput() uploads a file assuming a Linux to Windows upload always. when used in the opposite direction an extra 0x0D character is inserted because the 0x0A character is always replaced with 0x0D+0x0A. Reproduce code: --------------- <?php // usage: php test.php filename.txt username password server // filename.txt must have crlf at the end of every line. $conn_id = ftp_connect($argv[4]); if ( @ftp_login($conn_id, $argv[2], $argv[3]) ) { $fhand = fopen($argv[1], 'rb'); if ( $fhand ) { ftp_delete($conn_id, $argv[1]); $ftpmode = FTP_BINARY; // automatic ftp mode selection // Bug #39583 FTP function always transfers in binary mode // Bug FTP function converts text file into Windows Text file always while in ASCII mode. if ( eregi(".txt$",$argv[1]) ) $ftpmode = FTP_ASCII; // try to upload $file if (ftp_fput($conn_id, $argv[1], $fhand, $ftpmode, 0)) { echo "Successfully uploaded file\n"; } else echo "Found an error\n"; } } ?> Expected result: ---------------- filename.txt at server repository... In: CRLF Out: CRCRLF In: LF Out: CRLF Actual result: -------------- none -- Edit bug report at http://bugs.php.net/?id=41056&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=41056&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=41056&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=41056&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=41056&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=41056&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=41056&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=41056&r=needscript Try newer version: http://bugs.php.net/fix.php?id=41056&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=41056&r=support Expected behavior: http://bugs.php.net/fix.php?id=41056&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=41056&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=41056&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=41056&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=41056&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=41056&r=dst IIS Stability: http://bugs.php.net/fix.php?id=41056&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=41056&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=41056&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=41056&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=41056&r=mysqlcfg

« previous php.bugs (#111368) next »