Skip to content

Instantly share code, notes, and snippets.

@pierr
Last active August 29, 2015 14:26
Show Gist options
  • Save pierr/71203934c14e4e842c04 to your computer and use it in GitHub Desktop.
Save pierr/71203934c14e4e842c04 to your computer and use it in GitHub Desktop.
/**
<FileUpload>
{this.fieldFor('maProp')}
</Fileupload>
*/
module.exports = React.createClass({
render: function() {
return (
<form method='post' action={this.props.action} encType="multipart/form-data">
<h3>{this.props.title}</h3>
{this.props.children}
<input name="file" type="file"/>
<input type="submit" value="Submit" />
</form>
);
},
_onError: function _onError(){
if (this.props.onError !== undefined){
this.props.onError();
} else {
console.warn('Upload error');
}
},
_onSuccess: function _onSuccess(){
if (this.props.onSuccess !== undefined){
this.props.onSuccess();
} else {
console.info('Upload success');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment