Here is a working snippet:

if ($this->form->isValid())
{
   $file = $this->form->getValue('image');
 
$file->save(sfConfig::get('sf_cache_dir').'/uploaded'.$file->getExtension($file->getOriginalExtension()));

   $this->form->save();

   $this->redirect('somewhere');
}

Fabien

Slick Rick wrote:
> So I'm trying to upload files and save them to the server...
>  
> In my form I have:
>  
> $this->setValidatorSchema(
>  new sfValidatorSchema(array(
>    'image' => new sfValidatorFile(array('required' => false, 
> 'mime_categories' => 'web_images')),
>  ),
>  array('allow_extra_fields' => true)
>  ));
>  
> After I post the form, it passes the isValid() check and I can see the 
> file data listed by $this->getRequest()->getFiles('product');
>  
> Now, When I try to $form->getValue('image'), I get the following error:
>  
> Catchable fatal error: Method sfValidatedFile::__toString() must return 
> a string value in /path/to/module/actions/actions.class.php on line 265
>  
> If I do $form['image']->getValue(), I get nothing, just empty.
>  
> What it looks like I am trying to do is get an instance of 
> sfValidatedFile() so I can procede with the save() method.  Is there a 
> bug in the system, or am I doing it wrong?
>  
> Thanks,
>  
> --ian
> 
> > 

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"symfony developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/symfony-devs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to