Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function add() {
- if (!empty($this->data)) {
- $this->Project->set($this->data);
- if($this->Project->validates()) {
- $this->Project->create();
- if ($this->Project->save($this->data)) {
- if(!empty($this->data['Project']['fileNameProject']['name']))
- {
- $name = $this->Project->id.'_'.rand(1,10);
- $ext = '.'.$this->Uploader->ext($this->data['Project']['fileNameProject']['name']);
- if ($data = $this->Uploader->upload('fileNameProject', array('overwrite' => true,'name' => $name )))
- {
- $this->Uploader->resize(array('width' => 800, 'append'=>'resize','quality' => 80));
- $dest = 'uploaded/projects/'.$name.'resize'.$ext;
- $old = 'uploaded/projects/'.$name.$ext;
- $this->Uploader->rename($dest,$old,true);
- $this->Uploader->delete($dest,true);
- $this->Project->saveField('poza',$name.$ext);
- }
- }
- }
- $this->Session->setFlash(__('The project has been saved', true));
- $this->redirect(array('action' => 'index'));
- $this->Session->setFlash(__('The project could not be saved. Please, try again.', true));
- }
- }
- else{
- die("eroare");
- }
- }
- $developers = $this->Project->Developer->find('list');
- $users = $this->Project->User->find('list');
- $this->set(compact('users','developers'));
- }
Add Comment
Please, Sign In to add comment