react-images-upload icon indicating copy to clipboard operation
react-images-upload copied to clipboard

on upload, uploading the first image two times

Open HammadAli-WD opened this issue 4 years ago • 0 comments

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} />

HammadAli-WD avatar Feb 28 '21 16:02 HammadAli-WD