Laravel-Backpack / CRUD

Build custom admin panels. Fast!
https://backpackforlaravel.com
MIT License
3.11k stars 890 forks source link

How to preview files/upload_multiple? #5550

Closed blessen131 closed 2 months ago

blessen131 commented 3 months ago

I am trying to upload multiple files (backpack:5.x )

  1. Files selected. After save, they will show up above. this is the message I am getting after uploading files. How to preview file after upload? $this->crud->addfield([ 'name' => 'files', 'label' => 'Files', 'upload' => true, 'type' => 'upload_multiple', 'disk' => 'uploads', ]);

  2. How to save file as original name + date

  3. File .msg is not downloading it is opening in browser

jcastroa87 commented 3 months ago

Hello @blessen131

You didn't get a preview of file with this field, just a link to download. If you want to preview an image, you have others fields, like Image Pro amongs others you can see in our documentation

As our docs says:

The uploadMultipleFilesToDisk() method will take care of everything for most use case.

If you wish to have a different functionality, you can delete the method call from your mutator and do your own thing.

Cheers.

blessen131 commented 3 months ago

If the field type is ‘upload’ it will show the added file but when the field type is upload_multiple it is not showing the file name instead of file name I can see the label updated like this ‘Files selected. After save, they will show up above.’

pxpm commented 2 months ago

Hey @blessen131 thank you so much for the heads up.

Indeed, I agree there is a misalignment between both upload fields. I've had the need to show the selected files before myself, but never got the time to spend here creating something that "works" out of the box.

I took that time now and I've created a PR in #5576 if you test it, or have any other context to add, please do it on the PR thread 🙏

Thanks again! Cheers