我试图访问HTMLElementInput.files.path
发送到我的后端cloudinary
进行处理。我遇到的问题是对象上现在有path
键。无法访问文件上传路径密钥
我一直在读通过MDN Input page,我敢肯定我没有做错什么用的标记。下面是我拦截input
上的数据的代码:
class App extends Component {
capture(e) {
e.preventDefault();
const image = document.querySelector('input').files[0];
console.log(image);
// image.path === undefined
}
render() {
return (
<div className="App">
<div className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<h2>Welcome to React</h2>
</div>
<form onSubmit={e => this.capture(e)}>
<div>
<label htmlFor="photo_image">Upload an image</label>
<input id="photo_image" type="file" accept=".jpg, .jpeg, .png" />
</div>
<button type="submit">Submit</button>
</form>
</div>
);
}
}
export default App;
我很难过。如果有人看到我要去的地方有错,或者有和与react
,我不知道我是谁的耳朵!
更新
我以前离开了这个信息,我的道歉。该项目由create-react-app
引导。我在开发过程中遇到了这个问题,以及在构建生产服务时遇到这个问题。
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
传递单,当你不需要括号论据 – rockchalkwushock
感谢您更新我的知识。 –