PHP 8.5.0 Alpha 2 available for testing

Voting

: min(zero, three)?
(Example: nine)

The Note You're Voting On

Jarrod Christman
8 years ago
David's code works wonderfully except for one thing, it wouldn't upload a file until I placed a forward slash after '$sftp'

public function uploadFile($local_file, $remote_file)
{
$sftp = $this->sftp;
// Original
// "ssh2.sftp://$sftp$remote_file"
$stream = @fopen("ssh2.sftp://$sftp/$remote_file", 'w');

if (! $stream)
throw new Exception("Could not open file: $remote_file");

$data_to_send = @file_get_contents($local_file);
if ($data_to_send === false)
throw new Exception("Could not open local file: $local_file.");

if (@fwrite($stream, $data_to_send) === false)
throw new Exception("Could not send data from file: $local_file.");

@fclose($stream);
}

<< Back to user notes page

To Top