kartik-v / bootstrap-fileinput

An enhanced HTML 5 file input for Bootstrap 5.x/4.x./3.x with file preview, multiple selection, and more features.
http://plugins.krajee.com/file-input
Other
5.36k stars 2.4k forks source link

modal preview is white by ajax response #1734

Closed lj19950508 closed 3 years ago

lj19950508 commented 3 years ago

Prerequisites

Steps to reproduce the issue

1.upload with ajax , and response like image, and it can be preview by image type.

  1. but when it zoom it, it's blank image

Expected behavior and actual behavior

  1. Can type be identified by suffixes? just like image can identified by .png
  2. why thumbnail works but modal deital doesn'twork .

when not uploaded, every work , but when uploaded and use response option, i can't preview with modal detail

Environment

Browsers

Operating System

Libraries

kartik-v commented 3 years ago

Which plugin version are you using?

lj19950508 commented 3 years ago

bootstrap-fileinput-5.2.2

kartik-v commented 3 years ago

Not sure why - because it works fine on tests - You can cross check this with ajax demo example #4.

Check your app code and client browser has stale cache loading outdated assets. Check if any other javascript errors in your app on your client browser console.

Also test with the latest code on dev-master (v5.2.3 not released yet) and confirm.

lj19950508 commented 3 years ago

when i use batch upload button , it's works when i use simpe upload button , it doesn't work ; image

lj19950508 commented 3 years ago

image ajax demo example #4. , when i first upload with simple upload button , and it errors, but when i use batchupload button , it's ok

lj19950508 commented 3 years ago

@kartik-v If I don't define type by response, can I automatically adapt the preview file type according to the file suffix eg. .jpg ->image .pdf ->pdf .txt-> text because if i upload txtfile and return a pdffile without type , it will preview as image image

kartik-v commented 3 years ago

Yes the above behavior already exists in the plugin and you can override the default configurations via fileTypeSettings

lj19950508 commented 3 years ago

@kartik-v when i upload and response initialPreviewConfig without type fileTypeSettings doesn't work ,
i must be set attr type

this is response image

lj19950508 commented 3 years ago

prev comments add result image image

kartik-v commented 3 years ago

Yes for initialPreview you must set the type in initialPreviewConfig for each file from server to display the right template.... else default will be image