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?
1 Answer
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!
2 Comments
Keloo
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.
ckifer
So you should then be able to do
$request->files->add($arrayWithImageInIt)