Javascript 我需要帮助加载文件symfony2,在formbuilder中找不到输入名称

Javascript 我需要帮助加载文件symfony2,在formbuilder中找不到输入名称,javascript,php,jquery,symfony,Javascript,Php,Jquery,Symfony,我遵循Symfony 2.8中的文件上传指南 这是我的控制器 public function new1操作(请求$Request) { $pedido=新的Pedidos(); $form=$this->createForm(新的PedidosType,$pedido); 如果($request->getMethod()=='POST') { $image=$request->files->get('name_input_image'); 打印($image);退出; if(($image in

我遵循Symfony 2.8中的文件上传指南

这是我的控制器

public function new1操作(请求$Request)
{
$pedido=新的Pedidos();
$form=$this->createForm(新的PedidosType,$pedido);
如果($request->getMethod()=='POST')
{
$image=$request->files->get('name_input_image');
打印($image);退出;
if(($image instanceof UploadedFile)&&($image->getError()='0'))
{
$originalName=$image->getClientOriginalName();
$name_数组=分解('.',$originalName);
$file_type=$name_数组[sizeof($name_数组)-1];
$valid_filetypes=array('jpg','jpeg','png');
if(在数组中(strtolower($file\u type),$valid\u filetypes))
{
$document=新文档();
$document->setFile($image);
$document->setSubDirectory('archivos');
$document->processFile();
$pedido->setDescription($image->getBasename());
$em=$this->getdocument()->getManager();
$em->persist($pedido);
$em->flush();
$this->get('session')->getFlashBag()->add('mensaje',
"图像校正";;
返回$this->redirect($this->generateUrl('bd_pedidos'));
}否则
{
$this->get('session')->getFlashBag()->add('mensaje',
"建筑扩建工程",;
返回$this->redirect($this->generateUrl('bd_formnew1'));
} 
}否则
{
$this->get('session')->getFlashBag()->add('mensaje',
“无任何输入文件或生产文件中的错误”);
返回$this->redirect($this->generateUrl('bd_formnew1'));
}   
}
问题出现在
$image=$request->files->get('name\u input\u image');
'name\u input\u image'
是我视图中输入的名称。当我尝试使用常规输入(没有formbuilder)时,一切都很好,因为我可以控制输入的名称,但是当我使用formbuilder时,我不知道应该在
$image=$request->files->get('XXXXX');
中设置的输入的名称是什么

我还尝试了
{{form.task.vars.full_name}}
这可以返回
pedido_bdbundle_pedidos[description]
,但是当我使用
$image=$request->files->get('pedido_bdbundle_pedidos[description]);我的
$image
变量为空

我不知道问题在哪里,也不知道我能做什么

我的看法是:


{{form_标签(form.codArticulo)}
{{form_小部件(form.codArticulo)}
{{form_label(form.description)}}
{{form_widget(form.description)}}//这是我的图像字段
{{form_标签(form.abreviacion)}
{{form_小部件(form.abreviacion)}
{{form_标签(form.color)}
{{form_小部件(form.color)}
{{form_标签(form.cantidad)}
{{form_小部件(form.cantidad)}
{{form_标签(form.precio)}
{{form_小部件(form.precio)}
{{form_标签(form.envio)}
{{form_小部件(form.envio)}
{{form_标签(form.total)}
{{form_小部件(form.total)}
{{form_标签(form.fechaIni)}
{{form_小部件(form.fechaIni)}
{{form_标签(form.fechaFin)}
{{form_小部件(form.fechaFin)}
{{form_标签(form.flag)}
{{form_小部件(form.flag)}
{{form_rest(form)}
羡慕

可能问题出在我的实体中。有人知道如何在form builder中设置输入文件的名称吗

这是我的实体:

public function buildForm(formbuilder接口$builder,数组$options)
{
$builder->add('codArticulo',TextType::class,array('attr'=>array('class'=>'form-control','style'=>'margin-bottom:5px'))
->添加('description',FileType::class,array('attr'=>array('class'=>'form-control','style'=>'margin-bottom:5px'),'label'=>'Imagen','data\u class'=>null))
->添加('abreviacion',TextType::class,array('attr'=>array('class'=>'form-control','style'=>'margin-bottom:5px'))
->添加('color',TextType::class,array('attr'=>array('class'=>'form-control','style'=>'margin-bottom:5px'))
->添加('cantidad',TextType::class,array('attr'=>array('class'=>'form-control','style'=>'margin-bottom:5px'))
->添加('precio',TextType::class,array('attr'=>array('class'=>'form-control','style'=>'margin-bottom:5px'))
->添加('envio',TextType::class,array('attr'=>array('class'=>'form-control','style'=>'margin bottom:5px'))
->添加('total',TextType::class,array('attr'=>array('class'=>'form-control','style'=>'margin bottom:5px'))
->添加('fechaIni',DateType::class,array('widget'=>'single_text','html5'=>false,'input'=>'datetime','label'=>'Fecha Pedido','format'=>'dd/MM/yyyyy','read_'=>true',attr'=>['class'=>'form-control js datepicker','style'=>'页边距底部:5px','placeholder'=>'dd/MM/yyyyyyyy']))
->add('fechaFin',DateType::class,array('widget'=>'single_text','html5'=>false,'input'=>'datetime','label'=>'Fecha Entrega','format'=>'dd/MM/yyyyy','read_'=>true',attr'=>['class'=>'form-control js datepicker','style'=>'页边距底部:15px','placeholder'=>'dd/MM/yyyyyyy']))
->添加('flag',ChoiceType::class,array('attr'=>array('class'=>'form-control','style'=>'margin bottom:5px'),'disabled'=>false,'ChoiceType=>array('1'=>'Vigente','0'=>'Arrivaldo'),'required'=>true))
;
}
您只需要
public function new1Action(Request $request)
{
    $pedido = new Pedidos();
    $form = $this->createForm(new PedidosType, $pedido);
    if ($request->getMethod() == 'POST')
    {
        $form->handleRequest($request);
        $image = $pedido->getImage();
        //