Reputation: 45
I am using StofDoctrineExtensionsBundle for uploader Files with symfony2. When uploading a picture i have a error :
ContextErrorException: Notice: Undefined variable: size in /home/../AdsBundle/Entity/Fileupload.php line 135
src/../Controller/AdminUploaderController.php
public function uploadtestAction() { $f = new Fileupload(); $f->setName("why_use_linux.png"); $f->setPath("/home/ismail/Images/"); $f->setSize(1992894);
... }
src/../Entity/Fileupload.php
/** * Set mimeType * * @param string $mimeType * @return Fileupload */ public function setMimeType() { $this->mineType = $mineType; return $this; }
Is there any proposition to solve this problem?
Thanks,
Upvotes: 2
Views: 96
Reputation: 3959
It is easy my friend!
You just forgot to define your method setSize()
with the parameter $size
.
Redefine it as follows:
/**
* Set size
* @param decimal $size
* @return Fileupload
*/
public function setSize($size) { // param missing here!
$this->size = $size;
return $this;
}
Upvotes: 2
Reputation: 45
@aminejallouli The definition of the class of the variable size :
/** * @ORM\Column(name="size", type="decimal") * @Gedmo\UploadableFileSize */ private $size; /** * Set size * @param decimal $size * @return Fileupload */ public function setSize() { $this->size = $size; return $this; } /** * Get size * * @return decimal */ public function getSize() { return $this->size; }
Upvotes: 0