[英]How to get the file data from an html input form of type file, using refs in react.js
<input type="file" ref="file" size="45" />
我想從MSDN fileInputElement.files[0]
類似的信息,但是我這樣做了ReactDOM.findDOMNode(this.refs.file).files[0]
但是沒有返回任何數據。
this.refs.file.files[0]
對我來說很好
<input type="file" name="sendAttachment"
ref={(input) => { this.sendFile = input; }}
onChange={ (e)=>{this.sendAttachment(e) }} />
sendAttachment(e)
{
e.preventDefault();
console.log(this.sendFile.files[0]);
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.