$request->validate([
'file' => 'required|image|mimes:jpeg,png,jpg,pdf,xlx,csv,gif,svg|max:2048',
]);
// ============ process one ===============
$fileName = time().'.'.$request->file->extension();
$request->file->move(public_path('uploads'), $fileName);
return back()
->with('success','You have successfully upload file.')
->with('file',$fileName);
// ============ process one end===============
// ============ validation process two =====================
$validator = Validator::make(
$input,
[
'images.*' => 'required|mimes:jpg,jpeg,png,bmp|max:20000'
],[
'images.*.required' => 'Please upload an image',
'images.*.mimes' => 'Only jpeg,png and bmp images are allowed',
'images.*.max' => 'Sorry! Maximum allowed size for an image is 20MB',
]
);
if ($validator->fails()) {
// If fails then return Validation error..
}
// ============ validation process two end=====================
// ============ process two ===============
$path = $request->file('file')->store('uploade');
return back()
->with('success','You have successfully upload file.')
->with('file',$path);
// ============ process two end===============
// ============== validation process three =============
$this->validate($request, [
'images.*' => 'required|mimes:jpg,jpeg,png,bmp|max:2000'
],[
'images.*.required' => 'Please upload an image only',
'images.*.mimes' => 'Only jpeg, png, jpg and bmp images are allowed',
'images.*.max' => 'Sorry! Maximum allowed size for an image is 2MB',
]);
// ============== validation process three end=============
// ============ process three ===============
$fileName = time().'.'.$request->file->extension();
// You have to run this command php arisan storage:link
$path = $request->file('file')->storeAs(
'uploades', $fileName
);
return back()
->with('success','You have successfully upload file.')
->with('file',$fileName);
// ============ process three end===============