Think I am close, but cannot get it to work and output an image
So everything on S3 is set up, and currently a file is saved to S3 with a file size but when I try to open it, it says its corrupt or just brings up an empty square in the browser.
Base64 Example sent:
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAF4AAAA0AgMAAAB+02fBAAAADFBMVEUsPk8tdKUugbcugLcemMVGAAAABHRSTlP/8//Jq4gqhAAAABpJREFUeAFjgAOpVchgwwiUGJUYlRiVGJUAANbC6gCdtA2TAAAAAElFTkSuQmCC
In a method:
$fileName = "testimage.png";
$data = $request->image;
$data = base64_decode(preg_replace('#^data:image/\w+;base64,#i', '', $data));
$upload_success = Storage::disk('s3')->put('images/' . $fileName, $data);
Any help on getting this to successfully upload the image and possibly how I should go about getting the correct image extension?
Thanks.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire