0

In my controller I am using imagemagick to manipulate user uploaded image, then I store it in the public folder. The user sends the image along other data from a form. What I want to do is send the data as json to the ajax request and I do it like this:

return response()->json($Model);

I also want to send the $image I created with imagemagick along the data so that I don't have to make a server call from the javascript to download the image again. I have it there so how can I send that too?

Chriz74
  • 1,410
  • 3
  • 23
  • 47
  • See this: http://stackoverflow.com/questions/3967515/how-to-convert-an-image-to-base64-encoding – George G May 10 '17 at 18:05
  • I would guess an `echo` would work better than an `return` – RiggsFolly May 10 '17 at 18:08
  • @RiggsFolly like how? I converted the image to base64 and I am able to send it like this: `return response()->json(array('model' => $Model, 'image_for_preview' => $image_for_preview));` I mean, I tried `echo`, both send the data but what's the difference here? – Chriz74 May 10 '17 at 18:12

0 Answers0