我把我的网站从本地主机共享托管所有这是很好的,但是当我直接上传存储到的public_html文件,我需要:像这样的public_html /存储的东西/我试图使用somenthing这样的:
symlink('/home/abdoweb/bmcelarave/storage/app/public', '/bmce/public_html/storage')
问题仍然存在。
我的控制器:
public function addcategory(Request $request){
$title = $request->input('category_name');
$image = $request->file('category-image');
$name = $image->getClientOriginalName();
$image->move(storage_path().'/app/public/category',$name);
$data[] = $name;
$query= DB::table('category')->insert(
[
'title' => $title,
'image' => $name,
"created_at" => Carbon::now()
]);
if($query){
return redirect('categories');
}
}
我的文件夹:
家用/ abdoweb / {} bmcelaravel <=我的公用文件夹
核心laravel:
家/ {bmce} <=芯laravel
谢谢。
您可以将使用存储驱动程序:
内部配置/ filesystems.php:
'disks' => [
'public' => [
'driver' => 'local',
'root' => public_path() . '/uploads',
'url' => env('APP_URL').'/public',
'visibility' => 'public',
]
]
//Now you can move the file to storage like :
Storage::disk('public')->putFile('category', $request->file('category-image'));
首先对这些东西所有的推荐位置的是保持公共路径没有创造一个新的,除非有一个实际原因。你真的检查符号链接创建?
Laravel具有自己的命令的创建符号链接从storage/app/public
到public/storage
(存储文件夹将在后面生成):
php artisan storage:link
但是,如果你想创建默认符号链接,你应该建立一个为自己,就像你已经做了。
这是符号链接的模式:
ln -s target source
(在你的目标和源路径填写)
所以,如果你真正得到你的要求正确的文件,该代码应工作:
Storage::putFile($name, $request->file('category-image'));
欲了解更多,详细的相关信息查找到文件系统documentation