无法从PHP脚本(youtube-dl)写入共享驱动器

时间:2014-12-18 08:50:33

标签: php youtube youtube-dl

我使用了搜索 -

我在Windows服务器上有一个共享驱动器 从命令提示符我可以写这个运行youtube-dl的驱动器,但是从PHP脚本 - youtube-dl说permission error ( no permission error on local drive)

如果我以root身份从命令提示符运行包含youtube-dl的PHP脚本,它可以正常工作。

下面是php脚本

echo "Saving $v";
$url = "http://www.youtube.com/watch?v=$v";
$template = '/windowshare/%(id)s.%(ext)s';
$string = ('youtube-dl ' . escapeshellarg($url) . ' -f 22 -o ' .
          escapeshellarg($template));

$descriptorspec = array(
       0 => array("pipe", "r"),  // stdin
       1 => array("pipe", "w"),  // stdout
       2 => array("pipe", "w"),  // stderr
);
$process = proc_open($string, $descriptorspec, $pipes);
$stdout = stream_get_contents($pipes[1]);
fclose($pipes[1]);
$stderr = stream_get_contents($pipes[2]);
fclose($pipes[2]);
$ret = proc_close($process);
echo json_encode(array('status' => $ret, 'errors' => $stderr,
                   'url_orginal'=>$url, 'output' => $stdout,
                   'command' => $string));

1 个答案:

答案 0 :(得分:0)

这与php或youtube-dl无关 - 网络服务器正在运行的用户,因为它没有写入目标目录的权限。选择另一个目录或更改权限。例如,以root身份运行sudo chmod a+rw /windowshare以允许每个人写入目录。

相关问题