Level 73
Don't hardcode the extension, use $request->file('face_image')->extension();
Why are you decoding it?
Just read the manual on uploading files here
i have this code how can i store all kind of extensions jpg,jpeg, and png. in my code only storing jpg image. i need to store all images extensions. Using Laravel and API
function setFaceImage(Request $request, User $user) {
$image = base64_decode($request->face_image);
$storagePath = public_path() . "\" . "faceImage\FaceImage_" . $user->id . ".jpg";
file_put_contents($storagePath, $image);
$user->face_image = $storagePath;
$result = $user->save();
if($result)
{
$result = [
'data' => [
'Data Updated Successfully' ,
]
];
return response()->json($result , 200);
}
else
{
$result = [
'data' => [
'The operation has failed' ,
]
];
return response()->json($result , 200);
}
}
Please or to participate in this conversation.