It should be getClientOriginalExtension instead of getClientOrginalExtention.
The t should be an s in extension
this is my #controller
public function store(Request $request)
{
$this->validate($request, [
'title' => 'required',
'body' => 'required',
'cover_image' => 'image|nullable|max:1999',
]);
// Handle File upload
if($request->hasFile('cover_image')){
// get filename with the extention
$fileNameWithExt = $request->file('cover_image')->getClientOrginalName();
// get just filename
$fileName = pathinfo($fileNameWithExt, PATHINFO_FILENAME);
// get just Ext
$extention = $request->file('cover_image')->getClientOrginalExtention();
// Filename to store
$fileNameToStore = $filename.'_'.time().'.'.$extention;
// upload image
$path = $request->file('cover_image')->storeAs('public/cover_images',$fileNameToStore);
}else{
$fileNameStore='noimage.jpg';
}
//create post
$post=new Post;
$post->title = $request->input('title');
$post->body = $request->input('body');
$post->user_id = auth()->user()->id;
$post->cover_image = $fileNameToStore;
$post->save();
return redirect('/posts')->with('success','Post created');
}
why this error occurd ?
It should be getClientOriginalExtension instead of getClientOrginalExtention.
The t should be an s in extension
Please or to participate in this conversation.