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.

有帮助吗?

解决方案

Casing is important for React components. Try encType instead of ENCTYPE. (You should have seen a warning in your console suggesting that you use encType.)

Here's a complete list of tags and attributes:DOM Elements.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top