Get Uploaded File's Original Name

前端 未结 4 1501
日久生厌
日久生厌 2020-12-31 06:23
$request = $event->getRequest();
print_r($request->files);die;

gives me

Symfony\\Component\\HttpFoundation\\FileBag Object
(
         


        
4条回答
  •  迷失自我
    2020-12-31 07:07

    When you upload files you get UploadFile (API link) objects (basically the wrappers of array).

    $this->getRequest()->files[0]->getClientOriginalName();
    

    Can't try this now but you might need to do this instead:

    $this->getRequest()->files['name_of_file_field_in_post']->getClientOriginalName();
    

    where you would replace name_of_file_field_in_post with your form field's name.

提交回复
热议问题