In react, click on the image selected by input to get it with js.

my requirement is to click the picture button to trigger the click of < input type="file" >. Then you can select the picture, but how can the selected image be passed into the function of js.

here are two functions.

triggerUpload=()=>{
    const trig=document.getElementById("trig");
    trig.click();
  }
  handlePicReply=(files)=>{
    const trig=document.getElementById("trig");
    if(!files) return false;
    const container=document.getElementById("container");//container
    for(let i=0;i<files.length;iPP){
      const img = document.createElement("img");
      img.src = window.URL.createObjectURL(files[i]);
      img.height = 60;
      img.onload = function() {
        window.URL.revokeObjectURL(this.src);
      }
      container.appendChild(img);
    }
  }

< input id="trig" type="file" multiple accept="image/*" style= {{display:"none"}} onChange= {this.handlePicReply (this.files)} / >
/ / onChange. What should be the parameter of handlePicReply to pass into the selected file

/ / Click the picture button below to trigger input"s click
< Button size="small" onClick= {this.triggerUpload} > < Icon > image < / Icon > < / Button >

Jun.14,2022

Purple.

  

.
onChange= {() = > this.handlePicReply (this.files)}

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e5275a-446f9.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e5275a-446f9.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?