Call to a member function getClientOriginalExtension() on string this error come when i run my code
public function store(Request $request){
$file_ex=$request -> photo -> getClientOriginalExtension();
$file_name = $file_ex.time();
$path ='/images/users';
$request -> photo ->move($path, $file_name);
where the problem
file uploade , find out why this not working
At first, make sure of 3 things:
in enctype="multipart/form-data"
put it on form #tag like:
<form action="{{url('store')}}" method="POST" enctype="multipart/form-data">
$file = $request->photo; $file_ex =$file->getClientOriginalExtension(); $filename = time().rand(1,99).'.'.$file_ex; $path ='images/users'; $file->move(public_path($path),$filename);
Okay, this works fine.
go to config/filesystems.php
and scroll down until you will find 'disks' => [
In disks, you will find 'local' , 'public', and 's3' copy public and paste it on side 'public' and make some changes like:
At first, we will see
public :
'public' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'url' => env('APP_URL').'/storage',
'visibility' => 'public',
'throw' => false,
],
'root' => base_path().'/public/images/users',
or you can put which path you want.2: change the url, like 'url' => env('APP_URL').'/public',
or you can specify which URL you want.
The code will be:
'users' => [
'driver' => 'local',
'root' => base_path().'/public/images/users',
'url' => env('APP_URL').'/public',
'visibility' => 'public',
'throw' => false,
],
Thank you for your assistance, If there are any issues, just ask.