[英]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.