Quantcast
Channel: ReScript Forum - Latest posts
Viewing all articles
Browse latest Browse all 2592

Webapi and input files

$
0
0

am I correct in assuming the only way to get the files from a file input is to use %raw?

basically

const reader = new FileReader();
    reader.onload = (e) => {
      img.src = e.target.result;
    };
    reader.readAsDataURL(file);

I can query the Dom with Webapi and get the input element, but how do I read the files so I can pass it to a FileReader
I just spent an hour chasing my tail. asking chatgpt (useless btw) and got no where.

chatgpt :

let handleFileInputChange = (event: Dom.Event.t) => {
  let target = Dom.Event.target(event);
  switch (Dom.HtmlInputElement.files(target) {

but there’s no such function HtmlInputElement.files. also its missing a closing ) lol


Viewing all articles
Browse latest Browse all 2592

Trending Articles