首页 > 解决方案 > 生产模式下未定义的event.target.files react js

问题描述

我正在尝试通过输入将图像发送到 aws s3,这在开发模式下工作得很好,但是,当我在我的域上尝试它时,它不再工作它说无法获得未定义的属性。

const upload = async (e) => {

const S3client = new S3(config);
const teste = crypto.randomBytes(20).toString('hex');
let location = null;

console.log(e.target.files[0]);

await S3client.uploadFile(e.target.files[0], teste)
      .then(async (datum) => {
        location = datum.location;}
}

不知道为什么这不适用于生产模式

 <div className="upload-photo-contain">
        <form onChange={upload}>
          <input type="file" id="img" name="img" accept="image/*" />

                <label htmlFor="img">
                  <div className="upload-photo-box">

我就是这样称呼这个事件的

标签: javascriptnode.jsreactjs

解决方案


推荐阅读