I'm working with Laravel 5.3 and I have problem with post images to my api. I have external urls of images which come from social network api.
My Task is get this all items and post it to api without any form
, input
elements just from controller.
I fetch image from api and I can easily post text values but I struggle with images. I can use Image::make()
and make image from url;
$orig = pathinfo($media['image_url'], PATHINFO_EXTENSION);
$extension = substr($orig, 0, strpos($orig, '?'));
$filename = time().'-'.str_random(20).'.'.$extension;
// make image
$img = Image::make($media['image_url']);
if I return this $img
I got this object:
But I don't need to save it. I have to send it direct to api. If I try to set this object to $request->files
array where I receive POST
$request
before I save to DB
in I got this error:
But I want to set this image like that for able to use as uploadedFile:
How can I do this. I don't have any idea. Thanks! :)