You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jun 5, 2022. It is now read-only.
Hi ,
I am using the following code for uploading images, but when i check the array in db the first images uploaded two times. the problem occurs by selecting the images on by one.
onFileChange=(e) => {
/* this.setState({ imgCollection: [...this.state.imgCollection, ...e.target.files] }) */
this.setState({ imgCollection: this.state.imgCollection.concat(e) })
}
const formData = new FormData();
this.state.imgCollection.forEach(image => formData.append('imgCollection', image))
fetch('http://localhost:3005/apiHost/roomInputs', { method: 'POST', body: formData })
.then(res => {
console.log(res)
if (res.ok) {
this.props.history.push("/")
} else {
this.props.history.push("/roomData")
}})
Hi ,
I am using the following code for uploading images, but when i check the array in db the first images uploaded two times. the problem occurs by selecting the images on by one.
onFileChange=(e) => {
/* this.setState({ imgCollection: [...this.state.imgCollection, ...e.target.files] }) */
this.setState({ imgCollection: this.state.imgCollection.concat(e) })
}
const formData = new FormData();
this.state.imgCollection.forEach(image => formData.append('imgCollection', image))
fetch('http://localhost:3005/apiHost/roomInputs', { method: 'POST', body: formData })
.then(res => {
console.log(res)
if (res.ok) {
this.props.history.push("/")
} else {
this.props.history.push("/roomData")
}})
<ImageUploader
withIcon={false}
name="imgCollection"
buttonText='Choose images'
onChange={this.onFileChange}
imgExtension={['.jpg', '.gif', '.png', '.gif']}
maxFileSize={5242880}
withPreview={true}
/>
The text was updated successfully, but these errors were encountered: