我试图直接从php://input
流中解压zip文件。我跑Laravel家园,PHP 7.1.3-3+deb.sury.org~xenial+1
,与myproject.app/upload
端点,这里是curl
命令:解压缩或膨胀php://输入流?
curl --request POST \
--url 'http://myproject.app/upload' \
--data-binary "@myfile.zip" \
这是所有我试过的方法列表,其中所有的失败:
dd(file_get_contents('compress.zlib://php://input'));
file_get_contents()函数:不能代表类型输入的流作为文件描述
$fh = fopen('php://input', 'rb');
stream_filter_append($fh, 'zlib.inflate', STREAM_FILTER_READ, array('window'=>15));
$data = '';
while (!feof($fh)) {
$data .= fread($fh, 8192);
}
dd($data);
“”
$zip = new ZipArchive;
$zip->open('php://input');
$zip->extractTo(storage_path() . '/' . 'myfile');
$zip->close();
ZipArchive :: extractTo():无效的或者未初始化的对象邮编
这里是所有我对找到的链接subject:
http://php.net/manual/en/wrappers.php#83220
http://php.net/manual/en/wrappers.php#109657
http://php.net/manual/en/wrappers.compression.php#118461
https://secure.phabricator.com/rP42566379dc3c4fd01a73067215da4a7ca18f9c17
https://arjunphp.com/how-to-unpack-a-zip-file-using-php/
我开始认为这是不可能与PHP的内置的ZIP功能流进行操作。编写临时文件的开销和复杂性会非常令人失望。有谁知道如何做到这一点,或者它是一个错误?