nothing to link
you are trying to save directly into the public/img folder. Do you have permissions for that?
Any errors?
Is the image being stored somewhere else?
filesystems.php
'disks' => [
'local' => [
'driver' => 'local',
'root' => storage_path('app'),
],
'public' => [
'driver' => 'local',
'root' => public_path('img'),
'url' => env('APP_URL').'/img',
'visibility' => 'public',
],
's3' => [
'driver' => 's3',
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'region' => env('AWS_DEFAULT_REGION'),
'bucket' => env('AWS_BUCKET'),
'url' => env('AWS_URL'),
],
],
Controller to create category with image
public function catcreate(Request $request, Category $cat)
{
$validated = $this->validate($request,[
'name'=>'required|min:4',
'image'=>'required|image'
]);
if($request->hasFile('image')){
$filename = time() . '.' . $request->image->getClientOriginalExtension();
$request->image->storeAs('category', $filename, 'public');
$validated['image'] = $filename;
}
//store
$cat = Category::create($validated);
return redirect()->route('catindex')->withMessage('Category created successfully!');
}
Please or to participate in this conversation.