Laravel象征性链接不起作用



我有一些问题创建与laravel的符号链接,以访问我的存储中的文件

我将文件存储在 storageapppublic

我使用PHP Artisan命令创建链接 php artisan storage: link The [public/storage] directory has been linked.

早期文件存储在storageapppublic中,也可在publicstorage文件夹中看到

,但是现在它们仅存储在storageapppublic中,而在publicstorage文件夹中不可见

我正在使用链接显示文件路径 {{ Storage::url($package->reportPath['path']) }}路径显示正确,但它重定向到404页,因为我猜没有文件。

这在托管在EC2服务器上的Laravel 8上为我解决了。

rm public/storage
php artisan optimize:clear
php artisan storage:link

尝试删除您的公共/存储目录,然后尝试运行存储:再次链接。这对我有用。

如果要显示存储的文件使用资源((

asset('storage/further_path/').$file_name;

存储文件可以做

$destinationPath = storage_path('app/public/further_path'); 
if (!is_dir($destinationPath)) {
    mkdir($destinationPath, 0777, TRUE); 
} 
$request->file->move($destinationPath,$filename);

希望这对您有帮助。

让我知道您是否有问题。

最新更新