3

我正在尝试使用 React JS 编写一个带有输入文件类型的简单上传表单。当我提交文件时,它没有提交多表单数据。它正在提交纯输入文件名。

如果我们想在 React 中编写上传功能,我们是否需要进行任何其他更改。

上传的基本javascript代码(js小提琴链接):

    /** @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);

有人可以帮助我使用 React JS 编写代码。

4

1 回答 1

13

外壳对于 React 组件很重要。尝试encType代替ENCTYPE. (您应该在控制台中看到一条警告,建议您使用encType.)

下面是标签和属性的完整列表:DOM 元素

于 2014-01-27T18:38:37.257 回答