我試圖訪問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
感謝您更新我的知識。 –