Hello I am a Novice Coder so Please Try to be As Clear as Possible (for the sake of anyone Reading This For Help)
and be Understanding
Anyways
I want to Read a Files Metadata and store them as a Var
mainly an Images Metadata
What I am Trying to do is
to Get The Width and Height of an Image
What I Plan To do is
Set An Embeds params to the Width and Height of an Image
(which I know How to do)
So How do I do it
I have Code (Not Formatted) if you Want to Look at it
const output = document.getElementById('output'); const button = document.getElementById('submitbtn') const button2 = document.getElementById('removebtn') if (window.FileList && window.File) { document.getElementById('file-selector').addEventListener('change', event => { output.innerHTML = ''; for (const file of event.target.files) { const li = document.createElement('li'); var input = document.getElementById("file-selector").files[0]; const name = file.name ? file.name : 'NOT SUPPORTED'; const type = file.type ? file.type : 'NOT SUPPORTED'; const size = file.size ? file.size : 'NOT SUPPORTED'; const mod = file.lastModified ? file.lastModified : 'NOT SUPPORTED'; var isimage = type.includes("image"); var isaudio = type.includes("audio"); var isvideo = type.includes("video"); var height = file.height ? file.height : 'NOT SUPPORTED'; var width = file.width ? file.width : 'NOT SUPPORTED'; var path = document.getElementById("file-selector").value dateObj = new Date(mod * 1000); utcString = dateObj.toUTCString(); time = utcString.slice(-11, -4); console.log(type + name + size + isaudio + isimage + isvideo) var hrmod = "???" var trusize = bytesToSize(size) if (size > 8388608) { li.textContent = `The File is Too Big To Submit As it Excced Discord's 8Mb limit on file's Try again You can Try Changing the format or Lowering the Quality of the file`; output.appendChild(li); document.getElementById("file-selector").value = ''; button.disabled = true } else { var fileobject = URL.createObjectURL(document.getElementById("file-selector").files[0]) document.getElementById("img").src = fileobject; li.textContent = `name: ${name}, type: ${type}, size: ${trusize} last modified: ${time} path: ${path} object: ${fileobject} width: ${width} height: ${height}`; output.appendChild(li); button.disabled = false; button2.disabled = false; }; }; }); }
Edit: I am Making a Upload to Discord Form It is For Art COntest Everything is Working i am Just Polishing it Up to Be Better
The ID of the File Input is file-selector
Also button and button2 are the Upload and Submit Buttons and Clear File Buttons