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
Add a ment  | 

1 Answer 1

Reset to default 13

Casing 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