在PHP中使用curl上载失败
我想在ssh和PHP中使用curl,我做到了,但这个程序有时在PHP中不起作用 我在ssh中运行了它,它成功地工作了:在PHP中使用curl上载失败,php,ubuntu,curl,ssh,upload,Php,Ubuntu,Curl,Ssh,Upload,我想在ssh和PHP中使用curl,我做到了,但这个程序有时在PHP中不起作用 我在ssh中运行了它,它成功地工作了: curl -F video=@123.mp4 "https://example.com" 但当我用PHP编写此代码时,它已上载,但未完成: include('Net/SSH2.php'); $ssh = new Net_SSH2('ip'); if (!$ssh){ echo 'Error'; } else { $ssh->login('username
curl -F video=@123.mp4 "https://example.com"
但当我用PHP编写此代码时,它已上载,但未完成:
include('Net/SSH2.php');
$ssh = new Net_SSH2('ip');
if (!$ssh){
echo 'Error';
} else {
$ssh->login('username','password') or die("Login failed");
$ssh->exec('curl -F video=@123.mp4 "https://example.com"');
}
有什么问题吗?使用这些函数。通过exec()
调用执行的任何操作都可以直接使用这些函数完成,从而节省大量连接和shell调用
例如:
$connection = ssh2_connect('shell.example.com', 22);
ssh2_auth_password($connection, 'username', 'password');
$stream = ssh2_exec($connection, 'curl -F video=@123.mp4 "https://example.com"');
您正在尝试上载较大的文件吗?因为上载文件时PHP可能会超时。我建议您尝试在几KB内使用较小的文件,如果可以,然后确认代码工作正常,那么您应该增加超时
设置时间限制(0)
并运行代码谢谢,但我做到了,我仍然有问题:(您正在尝试上载较大的文件吗?因为上载文件时PHP可能会超时。我建议您尝试在几KB内使用较小的文件,如果可以,然后确认代码工作正常,那么您应该增加超时设置时间限制(0)
并运行代码