2

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,

1
  • 1
    Please provide us the definition of your class to check the definition of the variable size. Commented Oct 8, 2014 at 7:19

2 Answers 2

2

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;
}
Sign up to request clarification or add additional context in comments.

Comments

0

@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;
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.