xref: /PHP-8.4/ext/ftp/tests/ftp_append.phpt (revision e9f783fc)
1--TEST--
2ftp_append() create new file and append something
3--EXTENSIONS--
4ftp
5pcntl
6--FILE--
7<?php
8require 'server.inc';
9
10$ftp = ftp_connect('127.0.0.1', $port);
11if (!$ftp) die("Couldn't connect to the server");
12
13var_dump(ftp_login($ftp, 'user', 'pass'));
14
15$fooPath = __DIR__ . '/ftp_append_foo';
16file_put_contents($fooPath, 'foo');
17var_dump(ftp_append($ftp, 'ftp_append_foobar', $fooPath, FTP_BINARY));
18
19$barPath = __DIR__ . '/ftp_append_bar';
20file_put_contents($barPath, 'bar');
21var_dump(ftp_append($ftp, 'ftp_append_foobar', $barPath, FTP_BINARY));
22
23$fooBarPath = __DIR__ . '/ftp_append_foobar';
24var_dump(file_get_contents($fooBarPath));
25
26ftp_close($ftp);
27?>
28--CLEAN--
29<?php
30$fooPath = __DIR__ . '/ftp_append_foo';
31unlink($fooPath);
32$barPath = __DIR__ . '/ftp_append_bar';
33unlink($barPath);
34$fooBarPath = __DIR__ . '/ftp_append_foobar';
35unlink($fooBarPath);
36?>
37--EXPECT--
38bool(true)
39bool(true)
40bool(true)
41string(6) "foobar"
42