on-internet
← Community

Upload a image with fetch

Stack Overflow ·

I have a form defined: <form method="POST" onSubmit={this.handleSubmit.bind(this)} enctype="multipart/form-data"> The handler for the submit event is defined as such: handleSubmit(event) { event.preventDefault(); var FormData = require('form-data'); var form = new FormData(); form.append('nome', this.refs.name.value); form.append('phone', this.refs.phone.value); form.append('address', this.refs.address.value); form.append('mail', this.refs.mail.value); form.append('type', 'file'); form.append('photo', this.refs.photo.value); const {dispatch} = this.props; dispatch(fetchByArray(form)); } } fetc

Comments

Sign in or sign up to comment and upvote.

No comments yet.