Symfony file upload - An "array" stored in the database, not the actual file name

I am using Symfony 1.4.4 and Doctrine, and I need to upload the image to the server.

I did this hundreds of times without any problems, but this time something strange happens: instead of the name of the file stored in the database, I find the string "Array".

That's what I'm doing:

In my form:

$this->useFields(array('filename'));
$this->embedI18n(sfConfig::get('app_cultures'));

$this->widgetSchema['filename'] = new sfWidgetFormInputFileEditable(array(
      'file_src'  => '/uploads/flash/'.$this->getObject()->getFilename(),
      'is_image'  => true,
      'edit_mode' => !$this->isNew(),
      'template'  => '<div id="">%file%</div><div id=""><h3 class="">change picture</h3>%input%</div>',
    ));

    $this->setValidator['filename'] = new sfValidatorFile(array(
      'mime_types' => 'web_images',
      'path' => sfConfig::get('sf_upload_dir').'/flash',
    ));

In my action:

public function executeIndex( sfWebRequest $request )
    {
        $this->flashContents = $this->page->getFlashContents();

        $flash = new FlashContent();
        $this->flashForm = new FlashContentForm($flash);

        $this->processFlashContentForm($request, $this->flashForm);

    }

protected function processFlashContentForm($request, $form)
    {
      if ( $form->isSubmitted( $request ) ) {
     $form->bind( $request->getParameter( $form->getName() ), $request->getFiles( $form->getName() ) );
     if ( $form->isValid() ) {
  $form->save();
  $this->getUser()->setFlash( 'notice', $form->isNew() ? 'Added.' : 'Updated.' );
  $this->redirect( '@home' );
     }
 }
    }

Before linking my parameters, everything is fine, it $request->getFiles($form->getName())returns my files. But then it $form->getValue('filename')returns the string "Array".

Has any of you happened, or are you seeing something wrong with my code?

Edit: I added that I am implementing another form, which may be a problem (see form code above).

+3
2

, . .

:

$this->setValidator('filename', new sfValidatorFile(array(
  'mime_types' => 'web_images',
  'path' => sfConfig::get('sf_upload_dir').'/flash',
)));

, , , .

+3

;

$this->validatorSchema['filename']

<

$this->setValidator['filename']
0

Source: https://habr.com/ru/post/1743360/


All Articles