public function loading(Request $request)
{
$validation = Validator::make($request->all(), [
'icon' => 'image|mimes:jpeg,png,jpg,gif|max:2048'
]);
if($validation->passes())
{
$image = $request->file('icon');
$new_name = rand() . '.' . $image->getClientOriginalExtension();
$image->move(public_path('images'), $new_name);
return response()->json([
'message' => 'Image Upload Successfully',
'uploaded_image' => '<img src="/images/'.$new_name.'" class="img-thumbnail" width="300" />',
'class_name' => 'alert-success'
]);
}
else
{
return response()->json([
'message' => $validation->errors()->all(),
'uploaded_image' => '',
'class_name' => 'alert-danger'
]);
}
}