File: ssh2_sftp_002.phpt

package info (click to toggle)
php-ssh2 1.3.1%2B0.13-7
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 472 kB
  • sloc: ansic: 5,963; xml: 477; pascal: 38; makefile: 1
file content (28 lines) | stat: -rw-r--r-- 560 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
--TEST--
ssh2_sftp - SFTP tests
--SKIPIF--
<?php
  require('ssh2_skip.inc');
  ssh2t_needs_auth();
  ssh2t_remote_writes();
--FILE--
<?php require('ssh2_test.inc');

$ssh = ssh2_connect(TEST_SSH2_HOSTNAME, TEST_SSH2_PORT);
ssh2t_auth($ssh);
$sftp = ssh2_sftp($ssh);

$filename = ssh2t_tempnam();

$fp = fopen("ssh2.sftp://$sftp/$filename", 'w');
fwrite($fp, "Hello World\n");
fwrite($fp, "Goodbye Planet\n");
fclose($fp);

readfile("ssh2.sftp://$sftp/$filename");

var_dump(ssh2_sftp_unlink($sftp, $filename));
--EXPECT--
Hello World
Goodbye Planet
bool(true)