This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use the new forum.
Home » support » General discussion » Saving files in folders generated at runtime
Saving files in folders generated at runtime [message #96592] Thu, 01 April 2010 12:01 Go to next message
Latios88  is currently offline Latios88
Messages: 64
Registered: February 2010
Member
I have a form which has a file upload widget.
I need the file to be saved like this:

uploads/
/teamid
/file_id
/file

teamid is a property of the object that i am saving and the file id will be the generated id from doctrine.

How can this be done.

[Updated on: Fri, 02 April 2010 11:08]

Re: Saving files in folders generated at runtime [message #96860 is a reply to message #96592 ] Tue, 06 April 2010 16:14 Go to previous messageGo to next message
Latios88  is currently offline Latios88
Messages: 64
Registered: February 2010
Member
Aynone?
At least i want to store in a subfolder which name is a property of the object.

I have tried this:
'path' => sfConfig::get('upload_dir').$this->getObject()->getIdTeam().'/',

and also in doSaveMethod but it doesn´t work.

Any tips?
Re: Saving files in folders generated at runtime [message #97187 is a reply to message #96860 ] Mon, 12 April 2010 15:39 Go to previous message
Latios88  is currently offline Latios88
Messages: 64
Registered: February 2010
Member
 $this->validatorSchema['foto'] = new sfValidatorFile(array(
        'required'   => false,
          'path'=>'',
        'mime_types' => 'web_images',

        ),array('mime_types' => 'invalidFile')
            
   );


 protected function doSave($con = null){

     $values = $this->values;
     $file = $values['foto'];

     $filename = sha1($file->getOriginalName()).$file->getExtension($file->getOriginalExtension());

     $path = sfConfig::get('images_upload_dir').$this->getValue('id_team').'/';
     $file->save($path.$filename);
     return parent::doSave($con);
  }


The file is not being saved in filesystem.

Previous Topic:The rules of a .css are not applied to the templates of sfDoctrineGuardPlugin
Next Topic:How to make doctrine:build-sql task generate DROP statments ?
Goto Forum:
  

powered by FUDforum - copyright ©2001-2004 FUD Forum Bulletin Board Software