const FileiFyle = require('fileify-files')
const files = document.querySelector('input[type="file"]').files
window.onload = ()=> {
const file = new FileiFyle(files[0])
}The FileiFyle constructor supports an agrument of the Blob type. In this case what is used is the input from an
<input type="file" /><input type="file" id="fileInput" /> const fileInput = document.getElementById('fileInput')<input type="file" class="fileInput" />const fileInput = document.getElementsByClassName('fileInput')<input type="file">const fileInput = document.querySelector('input[type="file"]')When getting the file as a DOM element, you can use the following method:
file.getDomAs('img', img=> {
/* Do stuff with the DOM element */
})Note: When getting as an image, it returns an object of the Image() type, therefore you can't use functions like img.setAttribute(...)
'img''a''textNode''video'
The file.getAsDataURL(...) retruns a base-64 encoded string of the file.
file.getAsDataURL(url/* This is a base-64 encoded string */=> {
/* Do stuff with url */
})There are also the methods:
getAsBinary(...)getAsArrayBuffer(...)getAsText(...)