I am writing an API which is supposed to upload image and then return the url to access the image. Uploading is good but I am unable to access the image in url, can someone guide me how to access the image. Following is the code to upload the image.
public function uploadPicture(Request $request){
$file = base64_decode($request['image']);
$fileName = str_random(15).'.'.'png';
Storage::disk('local')->put($fileName, $file);
return $this->sendResponse(['url'=>asset('storage/'.$fileName)], 'Image is uploaded');
}
the response of the above api is
{
"success": true,
"data": {
"url": "http://localhost:8000/storage/BMqX7BC61XqjOhL.png"
},
"message": "Image is uploaded. "
}
The location is the image is project_root/storage/app
but in browser is say the 404 not found
can someone guide me how to access image in browser? I am using Laravel 5.7
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire