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 >