Мне нужен поток файлов.
Например
private function faviconFoundExec($url)
{
exec('wget ' . $url . ' -O ../favicons/test.jpg 2>&1', $output);
}
сохранит фактический файл, но мне нужен поток файлов, то же самое, что file_get_contents
вернется, как file_get_contents
ниже.
private function faviconFoundGet($url)
{
return @file_get_contents( $url );
}
Я смотрю на passthru, но документация немного неясна.
Вы можете получить поток из команды с proc_open
$descriptorspec = array(
0 => array("pipe", "r"), // stdin is a pipe that the child will read from
1 => array("pipe", "w"), // stdout is a pipe that the child will write to
2 => array("pipe", "w") // stderr is a pipe that the child will write to
);
$cmd = 'wget -qO- ' . $url;
$process = proc_open($cmd, $descriptorspec, $pipes, realpath('./'), array());
$contents = stream_get_contents($pipes[1]);
fclose($pipes[1]);
// It is important that you close any pipes before calling
// proc_close in order to avoid a deadlock
proc_close($process);