Get data from an object


I am having problems to get data from an object using POO in PHP. The object I have is the following (doing var_dump(request->$files) in symfony):

object(Symfony\Component\HttpFoundation\FileBag)#64 (1) {
  array(1) {
    array(1) {
      object(Symfony\Component\HttpFoundation\File\UploadedFile)#35 (6) {
        string(36) "12e846a1d8e3a88c89929600b6bdfb9f.jpg"
        string(10) "image/jpeg"
        string(24) "C:\xampp\tmp\php697B.tmp"
        string(11) "php697B.tmp"

I have tried with the following:

$image_name = $request->files('imagen');


$image_name = $request->files->get('imagen');


If you use the Symfony forms component then it’s as simple as

$file = $form['imagen']->getData();

Otherwise it’s

$file = $request->files->get('registro')['imagen'];



I´m trying to acces to the originalName attribute, but cannot access it. I´m trying with this:



You should read the Symfony docs on how to get the original name from an UploadedFile object.