@marcoplus Can you first make sure that you have this route /api/upload (I assume)?
Oct 8, 2024
8
Level 6
Api upload image An Error Occurred: Not Found
In my api I inserted this code, but when I try with postman I receive this error, but I don't understand where the mistake is and why it doesn't work
<div class="container">
<h1>Oops! An Error Occurred</h1>
<h2>The server returned a "404 Not Found".</h2>
<p>
Something is broken. Please let us know what you were doing when this error occurred.
We will fix it as soon as possible. Sorry for any inconvenience caused.
</p>
</div>
public function upload(Request $request)
{
try {
$photo = $request->file("image");
if($photo != null){
$ext = $photo->getClientOriginalExtension();
$fileName = rand(10000, 50000) . '.' . $ext;
if($ext == 'jpg' || $ext == 'JPG' || $ext == 'jpeg' || $ext == 'JPEG' || $ext == 'PNG' || $ext == 'png' || $ext == 'GIF' || $ext == 'gif'){
if($photo->move(public_path().'/uploadedphotos', $fileName)){
$porte = Porte::find($request->input('id'));
$porte->image = url('/') . "/public/uploadedphotos" . "/" . $fileName;
$porte->save();
return response(['result' => true]);
}
return response(['result' => false]);
}
} else{
return response(['result' => false]);
}
} catch (\Exception $exception){
return $exception->getMessage();
}
}
Level 70
@marcoplus there is a high possibility that your /api/porte-upload route is conflicted with other route.
I would like to ask you to share your whole route list without remove anything (if possible).
Can you also just dumping something in the beginning of the method?
public function upload(Request $request)
{
dd("I am here");
}
3 likes
Please or to participate in this conversation.

