Home  >  Article  >  Backend Development  >  php调用scp上传视频文件无法播放

php调用scp上传视频文件无法播放

WBOY
WBOYOriginal
2016-06-06 20:41:031261browse

使用PHP调用scp上传视频文件到目标服务器,上传之后无法播放,原视频文件可以正常播放。代码如下:

<code> <?php define('HOST', '192.169.1.100');
define('USER', 'root');
define('PWD', 'root');
define('SRC', '/var/www/html/upload/');

$mp4 = 'test.mp4';
$targetMp4 = SRC.'video/mp4/'.$mp4;

$connection = ssh2_connect(HOST, 22);
ssh2_auth_password($connection, USER, PWD);
ssh2_scp_send($connection, $mp4, $targetJpg, 0777);
</code></code>

想到以前用ftp上传的时候也出现过这种情况,更改为二进制模式上传之后可以解决,怀疑也是相同原因,但是ssh_scp_send函数没有设置上传模式的参数。不知如何解决?

回复内容:

使用PHP调用scp上传视频文件到目标服务器,上传之后无法播放,原视频文件可以正常播放。代码如下:

<code> <?php define('HOST', '192.169.1.100');
define('USER', 'root');
define('PWD', 'root');
define('SRC', '/var/www/html/upload/');

$mp4 = 'test.mp4';
$targetMp4 = SRC.'video/mp4/'.$mp4;

$connection = ssh2_connect(HOST, 22);
ssh2_auth_password($connection, USER, PWD);
ssh2_scp_send($connection, $mp4, $targetJpg, 0777);
</code></code>

想到以前用ftp上传的时候也出现过这种情况,更改为二进制模式上传之后可以解决,怀疑也是相同原因,但是ssh_scp_send函数没有设置上传模式的参数。不知如何解决?

为什么要用scp呢,scp传输的效率并不高。

可以用http传输,可以用rsync同步,方法多了

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn