Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uploading two fields #35

Closed
casoetan opened this issue Aug 7, 2012 · 11 comments
Closed

Uploading two fields #35

casoetan opened this issue Aug 7, 2012 · 11 comments
Labels

Comments

@casoetan
Copy link

casoetan commented Aug 7, 2012

When i try to upload two files, both in the same entity, but different fields, one is saved correctly and moved into the web directory, but the other is save temporarily in windows temp directory.

How do I fix this? thanks

@ftassi
Copy link
Collaborator

ftassi commented Aug 7, 2012

Maybe you are doing something wrong, are your entity annotations correct ? can you share with me ?

@casoetan
Copy link
Author

casoetan commented Aug 8, 2012

namespace CAS\SPA\RealtyBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use Vich\UploaderBundle\Mapping\Annotation as Vich;

/**
 * CAS\SPA\RealtyBundle\Entity\Projects
 * @ORM\Entity
 * @Vich\Uploadable
 */
class Projects
{
    /**
     * @var integer $id
     */
    private $id;

    /**
     * @var string $name
     */
    private $name;

    /**
     * @var string $image_name
     */
    private $image_name;

     /**
     * @Assert\File(
     *     maxSize="128k",
     *     mimeTypes={"image/png", "image/jpeg"}
     * )
     * @Vich\UploadableField(mapping="presentation_img", fileNameProperty="image_name")
     *
     * @var File $image
     */
    private $image;

    /**
     * @var text $discription
     */
    private $discription;

    /**
     * @var string $presentation
     */
    private $presentation;

     /**
     * @Assert\File(
     *     maxSize="2M",
     *     mimeTypes={"application/pdf", "application/x-pdf"}
     * )
     * @Vich\UploadableField(mapping="pdf_file", fileNameProperty="presentation")
     *
     * @var File $file
     */
    private $file;

    /**
     * Get id
     *
     * @return integer 
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set name
     *
     * @param string $name
     * @return Projects
     */
    public function setName($name)
    {
        $this->name = $name;
        return $this;
    }

    /**
     * Get name
     *
     * @return string 
     */
    public function getName()
    {
        return $this->name;
    }

    /**
     * Set image_name
     *
     * @param string $imageName
     * @return Projects
     */
    public function setImageName($imageName)
    {
        $this->image_name = $imageName;
        return $this;
    }

    /**
     * Get image_name
     *
     * @return string 
     */
    public function getImageName()
    {
        return $this->image_name;
    }

    /**
     * Set discription
     *
     * @param text $discription
     * @return Projects
     */
    public function setDiscription($discription)
    {
        $this->discription = $discription;
        return $this;
    }

    /**
     * Get discription
     *
     * @return text 
     */
    public function getDiscription()
    {
        return $this->discription;
    }

    /**
     * Set presentation
     *
     * @param string $presentation
     * @return Projects
     */
    public function setPresentation($presentation)
    {
        $this->presentation = $presentation;
        return $this;
    }

    /**
     * Get presentation
     *
     * @return string 
     */
    public function getPresentation()
    {
        return $this->presentation;
    }

    public function setImage($image) {
        $this -> image = $image;
    }

    public function getImage() {
        return $this -> image;
    }

    public function setFile($file) {
        $this -> presentation = $file;
    }

    public function getFile() {
        return $this -> presentation;
    }
}

@casoetan
Copy link
Author

casoetan commented Aug 8, 2012

thats my total entity file for the projects table, I'm using yaml for doctrine mapping not annotations.

@casoetan
Copy link
Author

casoetan commented Aug 9, 2012

image uploads fine, but the file /pdf/ uploads to the temp folder but does not rename. Still

@bertinl0609
Copy link

Same problem as you... did you find a solution ?

@K-Phoen K-Phoen mentioned this issue Dec 24, 2013
11 tasks
@davidromani
Copy link
Contributor

@casoetan maybe you have an error on file property getter and setter. Check this:

public function setFile($file) {
$this -> file = $file;
}

public function getFile() {
return $this -> file;
}

@meshenka
Copy link

any updates on this? i got a similar issue One entity, 2 fields

@K-Phoen
Copy link
Collaborator

K-Phoen commented Apr 10, 2014

I never had this problem.

There is an entity in my vich-uploader-sandbox with two uploadable fields. Maybe you can use it to check your code. If you still can't make it work, fork my sandbox and try to reproduce the bug in it (so that I can debug it myself).

@meshenka
Copy link

Thanks K-Phoen, i make it works like a charm :D

@FlYos
Copy link

FlYos commented Apr 15, 2014

I had the same issue. And I have emptied my development cache and after that the two files was successfully uploaded ;-)

@K-Phoen K-Phoen closed this as completed May 16, 2014
@kwn
Copy link

kwn commented Mar 3, 2015

The same situation here. Cache clearing solved this problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

8 participants