<input type="file" accept="image/*" onChange={async (ev) => { if (ev && ev.target && ev.target.files) { const formData = new FormData(); formData.append("file", ev.target.files[0], "file.jpg"); if(imageHTMLComponent) { const imageReader = new FileReader(); imageReader.onload = (ev) => { if( ev.target && typeof ev.target.result === "string") { test.setAttribute('src', ev.target.result); } } imageReader.readAsDataURL(ev.target.files[0]); const response = await fetch(`https://localhost:8000/test?token=${encodeURI('hello')}&picture=1`, { } } Preview of the image: <img ref={(ref) => {setImageHTMLComponent(ref)}} />
目前暂无任何回答
- 0 回答
- 0 关注
- 86 浏览
添加回答
举报
0/150
提交
取消