admin管理员组文章数量:1277896
I am trying to write a simple upload form with input file type using React JS. When i submit the file, it is not submitting multi form data. It is submitting plain input file name.
Do we need to make any other changes if we want to write upload functionality in React.
Basic javascript code for uploading (js fiddle link) :
/** @jsx React.DOM */
var HelloMessage = React.createClass({
render: function() {
return (<div>
<form name="secret" ENCTYPE="multipart/form-data" method="POST" action="http://localhost:8080/uploadFile">
Please choose two files to upload.
<br/>
File 1:<input type="file" id="profilePic" name="profilePic"/>
<br/>
<input type="submit" value="submit"/>
</form>
</div>);
}
});
React.renderComponent(<HelloMessage />, document.body);
Can someone help me to write using React JS.
I am trying to write a simple upload form with input file type using React JS. When i submit the file, it is not submitting multi form data. It is submitting plain input file name.
Do we need to make any other changes if we want to write upload functionality in React.
Basic javascript code for uploading (js fiddle link) :
/** @jsx React.DOM */
var HelloMessage = React.createClass({
render: function() {
return (<div>
<form name="secret" ENCTYPE="multipart/form-data" method="POST" action="http://localhost:8080/uploadFile">
Please choose two files to upload.
<br/>
File 1:<input type="file" id="profilePic" name="profilePic"/>
<br/>
<input type="submit" value="submit"/>
</form>
</div>);
}
});
React.renderComponent(<HelloMessage />, document.body);
Can someone help me to write using React JS.
Share Improve this question edited Jan 28, 2014 at 1:30 Rajeev asked Jan 27, 2014 at 16:45 RajeevRajeev 5,0029 gold badges46 silver badges68 bronze badges 2- 2 What you have posted is HTML, not JavaScript. – Anthony Grist Commented Jan 27, 2014 at 16:48
- 2 @AnthonyGrist i gave actual React JS code. Can you please have a look at this – Rajeev Commented Jan 27, 2014 at 17:00
1 Answer
Reset to default 13Casing is important for React ponents. Try encType
instead of ENCTYPE
. (You should have seen a warning in your console suggesting that you use encType
.)
Here's a plete list of tags and attributes:DOM Elements.
本文标签: javascriptSimple form submit with filesStack Overflow
版权声明:本文标题:javascript - Simple form submit with files - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741221763a2361091.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论