Laravel:从存储外部磁盘提取 ZipArchive 文件

问题描述 投票:0回答:1

我正在尝试提取位于 Laravel 应用程序的外部存储磁盘中的 ZipArchive 文件。它可以在我的本地环境中运行,但不能在生产环境中运行

编辑:我的

FILESYSTEM_DRIVER
环境变量在生产和工作中是不同的(与其他存储函数进行测试)

我有一个 zip 文件位于

Storage::path('folder/file.zip');
中,我正在尝试将其提取到同一文件夹中:

// path to the zip file
$path = Storage::path('folder/file.zip');

$zip = new ZipArchive;
if($zip->open($path) {
 $zip->extract(Storage::path('folder')); // working in local but not in production on an external disk
 $zip->close();
}

使用此代码,我收到代码 9 错误:没有此类文件 它说我的 $path 变量是错误的,但我的调试

Storage::exists('folder/file.zip');
返回
true

我不知道我在哪里遗漏了一些东西。我在网上找不到任何有帮助的答案。 任何帮助将不胜感激。

提前致谢

php laravel zip storage ziparchive
1个回答
-2
投票
$path = Storage::path('folder/file.zip');

$zip = new ZipArchive;
if($zip->open($path)) {
 $zip->extract(Storage::path('folder')); // working in local but not in production on an external disk
 $zip->close();
}
© www.soinside.com 2019 - 2024. All rights reserved.