Req #74582 [NEW]: Can not append to remote files with the ftp_* API

From: Date: Fri, 12 May 2017 12:50:51 +0000
Subject: Req #74582 [NEW]: Can not append to remote files with the ftp_* API
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-209085@lists.php.net to get a copy of this message
From: ndobromirov at gmail dot com Operating system: All PHP version: 7.1.5 Package: FTP related Bug Type: Feature/Change Request Bug description:Can not append to remote files with the ftp_* API Description: ------------ --- From manual page: http://www.php.net/ref.ftp --- This was tested against 5.6, but the ftp_append method is not present in PHP 7 too. Developers can append to FTP files through the streaming interfaces, but this is creating new FTP connections every time: file_put_contents('ftp://user:pass@exmaple.com:21/test.txt', "test\n", FILE_APPEND); The same is not possible through the dedicated FTP API provided with all of the ftp_* functions. There is no ftp_append function. And aparently this is also not possible with ftp_put and using the last parameter - offset (see test script). Test script: --------------- // Init... $ftp_connection = 'ftp://user:pass@example.com:21'; list ($source, $download) = ['test.txt', 'download.txt']; file_put_contents($source, "test\n"); // Connecnt... $remote = '/test_remote.txt'; $dsn = parse_url('ftp://user:pass@ftp:21'); if (!(($ftp = ftp_connect($dsn['host'], $dsn['port'])) !== false && ftp_login($ftp, $dsn['user'], $dsn['pass']))) { die('No log-in'); } // Test... @ftp_delete($ftp, $remote); for ($i = 0; $i < 3; ++$i) { if (ftp_put($ftp, $remote, $source, FTP_BINARY, $i ? ftp_size($ftp, $remote) : 0)) { ftp_get($ftp, $download, $remote, FTP_BINARY); echo file_get_contents($download), "\n"; } } Expected result: ---------------- test test test test test test Actual result: -------------- test test test -- Edit bug report at https://bugs.php.net/bug.php?id=74582&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=74582&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=74582&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=74582&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=74582&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=74582&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=74582&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=74582&r=needscript Try newer version: https://bugs.php.net/fix.php?id=74582&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=74582&r=support Expected behavior: https://bugs.php.net/fix.php?id=74582&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=74582&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=74582&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=74582&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=74582&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=74582&r=dst IIS Stability: https://bugs.php.net/fix.php?id=74582&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=74582&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=74582&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=74582&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=74582&r=mysqlcfg

« previous php.bugs (#209085) next »