Laravel-Backpack / medialibrary-uploaders

MIT License
10 stars 4 forks source link

[Bug] Upload field didn't save the file #6

Closed tabacitu closed 1 year ago

tabacitu commented 1 year ago

Bug report

What I did

Added an upload field with default media:

        CRUD::field('avatar')->type('upload')->withMedia([
            'collection' => 'default',
        ]);

What I expected to happen

Can upload file.

What happened

Tried to upload a file, but no... doesn't do it. Doesn't upload the file, doesn't store in the DB. Even though:

https://user-images.githubusercontent.com/1032474/221196397-3290760e-f701-462b-a11e-a3f80f0bff73.mp4

What I've already tried to fix it

Nothing. I assume there's something wrong with the uploader file?

tabacitu commented 1 year ago

I got the same problem with the upload_multiple field - files don't get saved as media in the DB, don't get uploaded to the disk. My definition was:

        CRUD::field('attachments')->type('upload_multiple')->withMedia([
            'collection' => 'default',
        ]);

I created a new DB column attachments (JSON) and I've added it to fillable.

pxpm commented 1 year ago

Fixed, withMedia() automatically adds the needed upload => true to fields.