--UPDATE--
So I am attempting to create a file previewer that allows someone to upload files with on the front end, access the browser files as a blob, and preview them in an iframe.
MUST BE ABLE TO PREVIEW ALL OPEN DOCUMENT FILES
My current issue is that viewer.js (http://viewerjs.org/instructions/) doesn't seem to work with blob files. This was the closest information I got..https://github.com/kogmbh/ViewerJS/issues/230
Any ideas on a way to have this work with all open document files? Plugin recommendations?
Current Code below..
fileUploadProcessFiles: function(fileInput){
console.log("MODALJS.fileUploadProcessFiles");
var m = $(document).find("#modal"),
list = $("#uploadList"),
files = fileInput.files,
type = m.find("option:selected").text();
for (var i = 0; i < files.length; i++) {
// Display List
list.append(`<div class='hundredWidth'>"+
<label class='autoWidth underline'>${type}</label><label class='cancelIconSmall inlineBlock' onclick='MODALJS.fileUploadRemoveFile(this)' style='margin-left: 10px'></label>
<label class='oneWide'>${files[i].name}</label>"
</div>`);
// Store Preview Links
var blobURL = URL.createObjectURL(files[i]);
MODALJS.fileUploadPreviewLinks.push(blobURL);
// Append Iframe Preview
list.append(`<iframe src="${MODALJS.fileUploadPreviewLinks[i]}" allowfullscreen webkitallowfullscreen width="400px" height="400px"></iframe>`);
// Push to upload queue
MODALJS.fileUploadFiles.push(["file", files[i]]);
}
},
--UPDATE #2--
So I got it figured out. I had to use a different plugin. webODF instead... I should be able to cobble together a decent enough solution now.
fileUploadProcessFiles: function(fileInput){
console.log("MODALJS.fileUploadProcessFiles");
var m = $(document).find("#modal"),
list = $("#uploadList"),
files = fileInput.files,
type = m.find("option:selected").text();
for (var i = 0; i < files.length; i++) {
// Display List
list.append(`<div class='hundredWidth'>"+
<label class='autoWidth underline'>${type}</label><label class='cancelIconSmall inlineBlock' onclick='MODALJS.fileUploadRemoveFile(this)' style='margin-left: 10px'></label>
<label class='oneWide'>${files[i].name}</label>"
</div>`);
// Store Preview Links
var blobURL = URL.createObjectURL(files[i]);
MODALJS.fileUploadPreviewLinks.push(blobURL);
// Append Iframe Preview
list.append(`<div id="odfCanvas"></div>`);
odfElement = document.getElementById("odfCanvas");
odfcanvas = new odf.OdfCanvas(odfElement);
odfcanvas.load(blobURL);
// Push to upload queue
MODALJS.fileUploadFiles.push(["file", files[i]]);
}
},