Git Product home page Git Product logo

laravel-file-viewer's Introduction

Laravel File Viewer - A package to see preview of diffrent file types

Latest Version on Packagist Total Downloads GitHub Twitter URL

Laravel File Viewer is a wrapper for implementing different JS libraries to view files according to their types. It supports images, videos, audio, docx, pptx, xlsx and pdfs etc.

Installation

You can install the package via composer:

composer require vish4395/laravel-file-viewer

Publish assets

php artisan vendor:publish  --provider="Vish4395\LaravelFileViewer\LaravelFileViewerServiceProvider" --tag=assets

Publish views (optional)(for customize ui)

php artisan vendor:publish  --provider="Vish4395\LaravelFileViewer\LaravelFileViewerServiceProvider" --tag=views

Usage

Add alias

    'aliases' => Facade::defaultAliases()->merge([
        'LaravelFileViewer' => Vish4395\LaravelFileViewer\LaravelFileViewerFacade::class,
    ])->toArray(),

Example

use LaravelFileViewer;
/*
 * ...
 */
public function file_preview($filename){
        $filepath='public/'.$filename;
        $file_url=asset('storage/'.$filename);
        $file_data=[
          [
            'label' => __('Label'),
            'value' => "Value"
          ]
        ];
        return LaravelFileViewer::show($filename,$filepath,$file_url,$file_data);
      }

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

You are most welcome to contribute this project Please see CONTRIBUTING for details. please email [email protected] for contribute this project or create PR.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

Demo:

AwesomeScreenshot-1_2_2023.1.32.27PM.mp4

laravel-file-viewer's People

Contributors

vish4395 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

laravel-file-viewer's Issues

Wrong JS scripts is loaded

in the layout file:
<script src="{{ asset('vendor/laravel-file-viewer/officetohtml/jquery/jquery.min.js') }}"></script>
that script does not exists

the assets that are published have this:

jquery-1.12.4.min.js
jquery-3.3.1.min.js
jquery-migrate-1.4.1.min.js

when trying to preview a .docx file I get theses error in th debug console

GET http://sign.test/vendor/laravel-file-viewer/officetohtml/jquery/jquery.min.js net::ERR_ABORTED 404 (Not Found)
network.js:71 The provided value 'moz-chunked-arraybuffer' is not a valid enum value of type XMLHttpRequestResponseType.
supportsMozChunkedClosure @ network.js:71
(anonymous) @ network.js:61
__w_pdfjs_require__ @ bootstrap b5fe8ab6eb949fc98816:19
(anonymous) @ pdf.js:34
__w_pdfjs_require__ @ bootstrap b5fe8ab6eb949fc98816:19
(anonymous) @ bootstrap b5fe8ab6eb949fc98816:65
(anonymous) @ bootstrap b5fe8ab6eb949fc98816:65
webpackUniversalModuleDefinition @ universalModuleDefinition:9
(anonymous) @ universalModuleDefinition:10
pptxjs.js:14 Uncaught TypeError: Cannot read properties of undefined (reading 'fn')
    at pptxjs.js:14:7
    at pptxjs.js:10187:2
(anonymous) @ pptxjs.js:14
(anonymous) @ pptxjs.js:10187
divs2slides.js:445 Uncaught TypeError: Cannot read properties of undefined (reading 'fn')
    at divs2slides.js:445:7
    at divs2slides.js:516:3
(anonymous) @ divs2slides.js:445
(anonymous) @ divs2slides.js:516
DevTools failed to load source map: Could not load content for http://sign.test/vendor/laravel-file-viewer/officetohtml/PPTXjs/js/nv.d3.min.js.map: HTTP error: status code 404, net::ERR_HTTP_RESPONSE_CODE_FAILURE
DevTools failed to load source map: Could not load content for http://sign.test/vendor/laravel-file-viewer/officetohtml/PPTXjs/css/nv.d3.min.css.map: HTTP error: status code 404, net::ERR_HTTP_RESPONSE_CODE_FAILURE
jquery.verySimpleImageViewer.js:12 Uncaught TypeError: Cannot read properties of undefined (reading 'fn')
    at jquery.verySimpleImageViewer.js:12:7
    at jquery.verySimpleImageViewer.js:581:2
(anonymous) @ jquery.verySimpleImageViewer.js:12
(anonymous) @ jquery.verySimpleImageViewer.js:581
officeToHtml.js:10 Uncaught TypeError: Cannot read properties of undefined (reading 'event')
    at officeToHtml.js:10:7
    at officeToHtml.js:11684:2
(anonymous) @ officeToHtml.js:10
(anonymous) @ officeToHtml.js:11684
show:128 Uncaught TypeError: $ is not a function
    at show:128:5
(anonymous) @ show:128
DevTools failed to load source map: Could not load content for http://sign.test/vendor/laravel-file-viewer/officetohtml/officeToHtml/viewer.js.map: HTTP error: status code 404, net::ERR_HTTP_RESPONSE_CODE_FAILURE
util.js:68 Uncaught TypeError: Cannot read properties of undefined (reading 'fn')
    at util.js:68:7
    at util.js:10:15
    at bootstrap.min.js:6:200
    at bootstrap.min.js:6:236
(anonymous) @ util.js:68
(anonymous) @ util.js:10
(anonymous) @ bootstrap.min.js:6
(anonymous) @ bootstrap.min.js:6

Unexpected Server Response

I get this error (Error: Unexpected server response. at officeToHtml.js:2466:39) when I try to view pdf file. The file is being downloaded successfully but not displayed in broswer.
Also, I get this error in the pdf viewer:
PDF.js v1.9.426 (build: 2558a58d)
Message: Unexpected server response (204) while retrieving PDF "http://127.0.0.1:8000/storage/Application%20form.pdf".

ANY IDEA? Please Help.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.