示例#1
0
 public function executeInsert()
 {
     // Qui ci arrivo solo se ho passato il validate
     // Quindi non devo fare controlli ...
     $file_name = $this->getRequest()->getFileName('file');
     $file_info = $this->getRequest()->getFile('file');
     $type = $file_info['type'];
     // Operazioni per il DB
     $file = new sfFileGallery();
     $file->setEntity($this->getRequestParameter('entity'));
     $file->setEntityId($this->getRequestParameter('entity_id'));
     $file->setName($file_name);
     $file->setMimeType($type);
     $file->setSize($file_info['size']);
     #$file->setSuffix($suffix);
     $file->setTitle($this->getRequestParameter('title'));
     $file->setDescription($this->getRequestParameter('description'));
     $file->setUploadedBy($this->getUser()->getId());
     $file->save();
     // UUID isn't correct until we reretrieve it
     $file = sfFileGalleryPeer::retrieveByPk($file->getId());
     //Operazioni per salvare il file in upload:
     $filePath = sfConfig::get('sf_upload_dir') . '/files/' . $file->getUuid();
     $this->getRequest()->moveFile('file', $filePath);
     // Fai il redirect dal referrer (TODO: oppure chiuditi come ajax)
     return $this->redirect($this->getRequestParameter('referer'));
 }
示例#2
0
 public function addsfFileGallery(sfFileGallery $l)
 {
     $this->collsfFileGallerys[] = $l;
     $l->setsfGuardUser($this);
 }