php:@fopen 在本地主机上工作但在实时服务器上不工作
php: @fopen works in localhost but not in live server
我正在尝试获取这样的远程文件:
$host = 'sftp.hostname.com';
$username = 'user';
$password = '*****';
$port = '22';
$remote_file = 'TOB-20180919.text';
$connection = @ssh2_connect($host, $port);
if ($connection != false) {
$login = @ssh2_auth_password($connection, $username, $password);
if ((bool) $login) {
$sftp = @ssh2_sftp($connection);
if ($sftp != false) {
$stream = @fopen("ssh2.sftp://$sftp" . "/" . "$remote_file", 'w');
var_dump($stream);exit;
}
}
}
$stream
在我的实时服务器中打印 false
并在我的本地主机中打印 true
。
我现在该怎么办?
我遇到了同样的问题,所以我使用以下方法解决了这类问题 code.please 使用这个并检查。
放
$stream = @fopen("ssh2.sftp://".(int)$sftp."/".$remote_file, 'w');
而不是
$stream = @fopen("ssh2.sftp://$sftp" . "/" . "$remote_file", 'w');
我正在尝试获取这样的远程文件:
$host = 'sftp.hostname.com';
$username = 'user';
$password = '*****';
$port = '22';
$remote_file = 'TOB-20180919.text';
$connection = @ssh2_connect($host, $port);
if ($connection != false) {
$login = @ssh2_auth_password($connection, $username, $password);
if ((bool) $login) {
$sftp = @ssh2_sftp($connection);
if ($sftp != false) {
$stream = @fopen("ssh2.sftp://$sftp" . "/" . "$remote_file", 'w');
var_dump($stream);exit;
}
}
}
$stream
在我的实时服务器中打印 false
并在我的本地主机中打印 true
。
我现在该怎么办?
我遇到了同样的问题,所以我使用以下方法解决了这类问题 code.please 使用这个并检查。
放
$stream = @fopen("ssh2.sftp://".(int)$sftp."/".$remote_file, 'w');
而不是
$stream = @fopen("ssh2.sftp://$sftp" . "/" . "$remote_file", 'w');