diff --git a/controllers/uploader.php b/controllers/uploader.php index bf06ec5..245ed36 100644 --- a/controllers/uploader.php +++ b/controllers/uploader.php @@ -1,2 +1,10 @@ getSize(); + } + return $size; +} + require_once LIB . 'vendor/fineuploader/php-traditional-server/endpoint.php'; diff --git a/public/js/explorer.js b/public/js/explorer.js index 2a46d19..b18bcde 100644 --- a/public/js/explorer.js +++ b/public/js/explorer.js @@ -273,6 +273,55 @@ $('div.actions > button', $mainSection).on('click', function() { } }); + } else if (action === 'display') { + $.ajax({ + url: 'http://supfile.tk/explorer', + type: 'POST', + data: {action: 'download', path: path}, + cache: false, + xhr: function() { + var xhr = new XMLHttpRequest(); + xhr.responseType = 'blob'; + return xhr; + }, + success: function(data) { + if (data != null && navigator.msSaveBlob) + return navigator.msSaveBlob(new Blob([data], {type: data.type}), ''); + var blob = new Blob([data], {type: data.type}); + var url = window.URL.createObjectURL(blob); + var tag; + if (data.type.split('/')[0] === 'image') { + tag = $(""); + } else if (data.type === 'application/pdf') { + tag = $('\n' + + ' It appears you don\'t have a PDF plugin for this browser.\n' + + ' No biggie... you can click here to\n' + + ' download the PDF file.\n' + + ' \n' + + ''); + } else if (data.type.split('/')[0] === 'video') { + tag = $('Woops we ran into an issue ... '); + } else if(data.type.split('/')[0] === 'audio'){ + tag = $('Woops we ran into an issue ... '); + }else if(data.type.split('/')[0] === 'text'){ + var myReader = new FileReader(); + myReader.addEventListener("loadend", function(e){ + $('#uploader').html(e.target.result); + }); + myReader.readAsText(blob); + } + //TODO: Add it to a modal instead + $("#uploader").append(tag); + + /* var a = $(""); + a.attr("href", url); + $("body").append(a);*/ + }, + error: function() { + + } + }); + } else { $.post('http://supfile.tk/explorer', {action: action, path: path}, function(data) { getList(data);
It appears you don\'t have a PDF plugin for this browser.\n' + + ' No biggie... you can click here to\n' + + ' download the PDF file.\n' + + '