0

I need to forward a POST request in Symfony but before forwarding I need to convert an image from base64 to $_FILES parameter. How can I do this?

Keloo
  • 1,368
  • 1
  • 17
  • 36

1 Answers1

3

Are you submitting a form before you forward? If you are you can do:

if($form->isSubmitted() && $form->isValid){
    //Do whatever work you need to in here like uploading the image 
    // before the forward
    return $this->forward('@Bundle:action', array(
       'request' => $request));
}

As for converting your file take a look at the answer to this question. It should do the trick. Hope this helps!

ckifer
  • 190
  • 1
  • 3
  • 14
  • The idea is to add the uploaded (converted from base64) image to the $_FILES before forward. Or to the $request->files because in the forwarded controller I need it as if it was submitted via POST from the browser. – Keloo Jul 28 '17 at 19:33
  • 1
    So you should then be able to do `$request->files->add($arrayWithImageInIt)` – ckifer Jul 28 '17 at 19:40