我在使用laravel创建符号链接以访问存储中的文件时遇到一些问题
我将文件存储在storage\app\public
中
我使用php artisan命令创建链接php artisan storage: link
The [public/storage] directory has been linked.
早期的文件存储在storage\app\public
中,也可以在public\storage
文件夹中看到
但现在他们只存储在storage\app\public
而在public\storage
文件夹中不可见
我正在使用链接显示文件路径{{ Storage::url($package->reportPath['path']) }}
路径显示正确但它重定向到404页面,因为我猜没有文件。
如果您尝试显示存储的文件,请使用asset()
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);
希望这有助于你。
让我知道你是否有任何问题。