Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/259.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/symfony/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何通过在Symfony中添加文件参数转发POST请求?_Php_Symfony - Fatal编程技术网

Php 如何通过在Symfony中添加文件参数转发POST请求?

Php 如何通过在Symfony中添加文件参数转发POST请求?,php,symfony,Php,Symfony,我需要在Symfony中转发POST请求,但在转发之前,我需要将图像从base64转换为$\u FILES参数。我怎样才能做到这一点?在转发之前您是否提交了表格? 如果你是,你可以做: if($form->isSubmitted() && $form->isValid){ //Do whatever work you need to in here like uploading the image // before the forward

我需要在Symfony中转发POST请求,但在转发之前,我需要将图像从base64转换为$\u FILES参数。我怎样才能做到这一点?

在转发之前您是否提交了表格? 如果你是,你可以做:

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));
}

至于转换文件,请看问题的答案。它应该会起作用。希望这有帮助

转发前是否提交表单? 如果你是,你可以做:

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));
}

至于转换文件,请看问题的答案。它应该会起作用。希望这有帮助

我们的想法是在转发之前将上传(从base64转换)的图像添加到$\u文件中。或者$request->files,因为在转发的控制器中,我需要它,就好像它是通过浏览器的POST提交的一样。因此,您应该能够执行
$request->files->add($arrayWithimaginit)
在转发之前,将上载(从base64转换)的图像添加到$\u文件中。或者$request->files,因为在转发的控制器中,我需要它,就像它是通过浏览器的POST提交的一样。因此,您应该能够执行
$request->files->add($arraywhichimaginit)