3

I'm using Elfinder for web file manager

When I double click the Pdf file, File is downloading.

File should be open in new window.

var y = window.open(a, "new_window", o + ",top=50,left=50,scrollbars=yes,resizable=yes");

In a changed to https://localhost. but still file downloads any other way to achieve this?

Maria Jeysingh Anbu
  • 3,164
  • 3
  • 34
  • 55

1 Answers1

0

While initializing, Add Custom handler in Elfinder as below.

var BASEURL='http://www.example.com/'; //your baseurl of site root.
var elf;
$(document).ready(function() {
elf = $('#elfinder').elfinder({
    url: BASEURL + '/YourURL', // connector URL (REQUIRED)
    height: 800, // in pixel
    handlers: {
        open: function(event) {
            sessionStorage.setItem('el_filepath', '');
        },
        select: function(event, elfinderInstance) {
            var selected = event.data.selected;
                if (selected.length) {
                var filepath = elfinderInstance.path(selected[0]);                    
                sessionStorage.setItem('el_filepath', filepath);
            }
        },
        dblclick: function(event, elfinderInstance) {
            var filepath = sessionStorage.getItem('el_filepath');
            var extension = filepath.split('.').pop();
            if (extension.trim() == 'pdf'.trim()) {
                window.open(BASEURL + filepath, '_blank');//Open Your File in new Tab.
            }
        }
    }
}).elfinder('instance');

});
Kamal
  • 64
  • 1
  • 4