Guest User

Untitled

a guest
Jun 23rd, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. function add() {
  2.  
  3. if (!empty($this->data)) {
  4.  
  5.  
  6. $this->Project->set($this->data);
  7. if($this->Project->validates()) {
  8. $this->Project->create();
  9. if ($this->Project->save($this->data)) {
  10. if(!empty($this->data['Project']['fileNameProject']['name']))
  11. {
  12. $name = $this->Project->id.'_'.rand(1,10);
  13. $ext = '.'.$this->Uploader->ext($this->data['Project']['fileNameProject']['name']);
  14. if ($data = $this->Uploader->upload('fileNameProject', array('overwrite' => true,'name' => $name )))
  15. {
  16. $this->Uploader->resize(array('width' => 800, 'append'=>'resize','quality' => 80));
  17. $dest = 'uploaded/projects/'.$name.'resize'.$ext;
  18. $old = 'uploaded/projects/'.$name.$ext;
  19. $this->Uploader->rename($dest,$old,true);
  20. $this->Uploader->delete($dest,true);
  21. $this->Project->saveField('poza',$name.$ext);
  22. }
  23. }
  24. }
  25. $this->Session->setFlash(__('The project has been saved', true));
  26. $this->redirect(array('action' => 'index'));
  27. $this->Session->setFlash(__('The project could not be saved. Please, try again.', true));
  28. }
  29. }
  30. else{
  31. die("eroare");
  32. }
  33. }
  34. $developers = $this->Project->Developer->find('list');
  35. $users = $this->Project->User->find('list');
  36. $this->set(compact('users','developers'));
  37. }
Add Comment
Please, Sign In to add comment