I am working on localhost. while updating/uploading image as buffer on the database, it is failing with error "net::ERR_CONNECTION_RESET" .
The file is not too large as well. So what is the solution to this? I am very much confused.
html part>>>
<input type="file" class="form-control" id="customFile" accept="image/*" ata-max-size="50000" multiple>
js part>>>
var imgform = document.querySelector('#customFile')
var formData = new FormData();
formData.append("image", imgform.files[0])
fetch(`/posts/image/${postId}`
,{
method: 'patch',
headers: {
'Authorization': 'Bearer '+token
},
body: formData
}
).then((response)=>{
console.log(response.status);
})
I've also been searching for what could cause this, and it looks like it might be something from the server, in the meantime, one thing I did that helped was to add keepalive: true
to the fetch methods like so:
var imgform = document.querySelector('#customFile')
var formData = new FormData();
formData.append("image", imgform.files[0])
fetch(`/posts/image/${postId}`
,{
method: 'patch',
keepalive: true,
headers: {
'Authorization': 'Bearer '+token
},
body: formData
}
).then((response)=>{
console.log(response.status);
})
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.