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

Advanced file type detection for preview irrespective of file extension #1792

Closed
7 of 18 tasks
PhantomLord72 opened this issue Jun 16, 2022 · 1 comment
Closed
7 of 18 tasks

Comments

@PhantomLord72
Copy link

PhantomLord72 commented Jun 16, 2022

Prerequisites

  • I have searched for similar issues in both open and closed tickets and cannot find a duplicate.
  • The issue still exists against the latest master branch of bootstrap-fileinput.
  • This is not an usage question. I confirm having read the plugin documentation and demos.
  • This is not a general programming / coding question. (Those should be directed to the webtips Q & A forum).
  • I have attempted to find the simplest possible steps to reproduce the issue.
  • I have included a failing test as a pull request (Optional).

Steps to reproduce the issue

  1. load some demo from http://plugins.krajee.com/file-input/demo, even the basic demo is not working
  2. load a pdf without extension
  3. click on the upload button

Expected behavior and actual behavior

When I follow those steps, I see... the preview show binary contents

I was expecting... the fileinput analyze the mimetype based on its contents header of the file and show the corresponding preview

Environment

Browsers

  • Google Chrome
  • Mozilla Firefox
  • Internet Explorer
  • Safari

Operating System

  • Windows
  • Mac OS X
  • Linux
  • Mobile

Libraries

  • jQuery version: 3.6.0
  • bootstrap-fileinput version: 5.2.7

Isolating the problem

  • This bug happens on the plugin demos page
  • The bug happens consistently across all tested browsers
  • This bug happens when using bootstrap-fileinput without other plugins
  • I can reproduce this bug in a jsbin
@kartik-v kartik-v changed the title Empty extensions Advanced file type detection for preview irrespective of file extension Jun 19, 2022
@kartik-v
Copy link
Owner

kartik-v commented Jun 19, 2022

New enhancements added with above commit.

  • Load the following new plugin files before fileinput.min.js - this is needed to auto parse the mime type based on file contents.
<!-- buffer.min.js and filetype.min.js are necessary in the order listed for advanced mime type parsing and more correct
     preview. This is a feature available since v5.2.9 and is needed if you want to ensure file mime type is parsed 
     correctly even if the local file's extension is named incorrectly. This will ensure more correct preview of the
     selected file (note: this will involve a small processing overhead in scanning of file contents locally). -->
<script src="https://cdn.jsdelivr.net/gh/kartik-v/[email protected]/js/plugins/buffer.min.js" type="text/javascript"></script>
<script src="https://cdn.jsdelivr.net/gh/kartik-v/[email protected]/js/plugins/filetype.min.js" type="text/javascript"></script>

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

No branches or pull requests

2 participants