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

Serialization of '...File' is not allowed when saving #64

Closed
schingeldi opened this issue Nov 9, 2012 · 1 comment
Closed

Serialization of '...File' is not allowed when saving #64

schingeldi opened this issue Nov 9, 2012 · 1 comment
Labels

Comments

@schingeldi
Copy link

I followed the documentation. But when saving I get the error:

Exception: Serialization of 'Symfony\Component\HttpFoundation\File\File' is not allowed

and

Exception: Symfony\Component\HttpKernel\DataCollector\RequestDataCollector::serialize() must return a string or NULL

When I remove the VichUploader Assertion

@Vich\UploadableField(mapping="organization_logo", fileNameProperty="headerLogoName")

then everything the error disappears and saving works. That's why I post this problem here. I googled a little bit and found, that other persons having similar problems, but not mentioning this Bundle.

Here are extracts of my code:

// Entity


    /**
     * @Assert\File(
     *     maxSize="1M",
     *     mimeTypes={"image/png", "image/jpeg", "image/pjpeg"}
     * )
     *@Vich\UploadableField(mapping="organization_logo", fileNameProperty="headerLogoName")
     *
     * @var File $image
     */
    protected $headerLogo;

    /**
     * @ORM\Column(type="string", length=255, name="header_logo_name")
     *
     * @var string $headerLogoName
     */
    protected $headerLogoName;



// form

$builder->add('headerLogoName', 'file');
# config
knp_gaufrette:
    adapters:
        organization_adapter:
            local:
                directory:  %acme.media_dir%/images/organization

    filesystems:
        organization_logo_fs:
            adapter:    organization_adapter


vich_uploader:
    db_driver: orm
    gaufrette: true
    storage: vich_uploader.storage.gaufrette
    mappings:
        organization_logo:
            uri_prefix: /images/organization/logo/
            upload_destination: organization_logo_fs

Thanks for any helps and thoughts

@aderuwe
Copy link

aderuwe commented Nov 26, 2012

I think the problem is:

$builder->add('headerLogoName', 'file');

Which I think should rather read:

$builder->add('headerLogo', 'file');

At the very least, that's what works for me.

@K-Phoen K-Phoen closed this as completed Dec 8, 2013
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

3 participants