Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [php+symfony] Error: Call to a member function move() on a non-object
dopelganger
post
Post #1





Grupa: Zarejestrowani
Postów: 236
Pomógł: 0
Dołączył: 27.10.2012

Ostrzeżenie: (0%)
-----


cześć
dodałem do profilu użytkownika możliwość upload obrazka (avatar), no i pięknie działa. Ale po zalogowaniu się do konta a następnie przekierowaniu -> wywala bład:

Error: Call to a member function move() on a non-object

czepia się o linię którą wyszczałkowałem (IMG:style_emoticons/default/smile.gif) Prosze o pomoc.


Kod klasy User.php

  1.  
  2. public function getFullImagePath() {
  3. return null === $this->image ? null : $this->getUploadRootDir(). $this->image;
  4. }
  5.  
  6. protected function getUploadRootDir() {
  7. // the absolute directory path where uploaded documents should be saved
  8. return $this->getTmpUploadRootDir().$this->getId()."/";
  9. }
  10.  
  11. protected function getTmpUploadRootDir() {
  12. // the absolute directory path where uploaded documents should be saved
  13. return __DIR__ . '/../../../../web/images/uploads/';
  14. }
  15.  
  16. /**
  17.   * @ORM\PrePersist()
  18.   * @ORM\PreUpdate()
  19.   */
  20. public function uploadImage() {
  21. // the file property can be empty if the field is not required
  22. if (null === $this->image) {
  23. return;
  24. }
  25. if(!$this->id){
  26. $this->image->move($this->getTmpUploadRootDir(), $this->image->getClientOriginalName());
  27. }else{
  28. $this->image->move($this->getUploadRootDir(), $this->image->getClientOriginalName()); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  29. }
  30. $this->setImage($this->image->getClientOriginalName());
  31. }
  32.  
  33. /**
  34.   * @ORM\PostPersist()
  35.   */
  36. public function moveImage()
  37. {
  38. if (null === $this->image) {
  39. return;
  40. }
  41. if(!is_dir($this->getUploadRootDir())){
  42. mkdir($this->getUploadRootDir());
  43. }
  44. copy($this->getTmpUploadRootDir().$this->image, $this->getFullImagePath());
  45. unlink($this->getTmpUploadRootDir().$this->image);
  46. }
  47.  
  48. /**
  49.   * @ORM\PreRemove()
  50.   */
  51. public function removeImage()
  52. {
  53. unlink($this->getFullImagePath());
  54. rmdir($this->getUploadRootDir());
  55. }


Ten post edytował dopelganger 23.09.2015, 13:46:50
Go to the top of the page
+Quote Post

Posty w temacie
- dopelganger   [php+symfony] Error: Call to a member function move() on a non-object   23.09.2015, 13:34:08
- - viking   Wstaw [PHP] pobierz, plaintext var_dump($this-...   23.09.2015, 16:25:49
|- - dopelganger   Cytat(viking @ 23.09.2015, 17:25:49 )...   24.09.2015, 07:21:37
- - thek   Ja bym już $this sprawdzał   23.09.2015, 19:40:52
- - memory   [PHP] pobierz, plaintext $this->setImage($...   24.09.2015, 07:48:28
|- - dopelganger   Cytat(memory @ 24.09.2015, 08:48:28 )...   24.09.2015, 08:09:53
- - memory   Podaj całą zawartość klasy   24.09.2015, 08:14:58
|- - dopelganger   Cytat(memory @ 24.09.2015, 09:14:58 )...   24.09.2015, 08:23:13
- - kapslokk   [PHP] pobierz, plaintext /**  * @var stri...   24.09.2015, 08:25:49
|- - dopelganger   Cytat(kapslokk @ 24.09.2015, 09:25:49...   24.09.2015, 08:29:23
- - kapslokk   Zapisuje, ale w 'image' przez to masz stri...   24.09.2015, 08:32:02
- - memory   Przeczytaj dokładnie dokumentacje. Czemu do zmienn...   24.09.2015, 08:38:41
- - dopelganger   wywala mi błąd: Catchable Fatal Error: Argument 1...   24.09.2015, 09:15:31
- - memory   [PHP] pobierz, plaintext $builder->add('fil...   24.09.2015, 09:42:19
|- - dopelganger   Cytat(memory @ 24.09.2015, 10:42:19 )...   24.09.2015, 09:45:21
- - ohm   Koduse Symfony\Component\HttpFoundation...   24.09.2015, 12:29:20
|- - dopelganger   Cytat(ohm @ 24.09.2015, 13:29:20 ) Ko...   24.09.2015, 13:22:15
- - kpt_lucek   Eh Rozdziel to na 2 przypadki: 1. masz model któr...   24.09.2015, 13:41:27
- - dopelganger   cześć sory, ale wracam jeszcze do tego tematu. Prz...   8.10.2015, 12:00:58


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 14.09.2025 - 17:21