I need to upload an image through a request, but when I upload, I find the following message:
'request entity too large'
Although I have configured the file size that will be received, what can I do to solve the problem?
Can u share the settings that you have changed and what's the file size?
@thetutlage First of all, thank you.
This is the function I'm using:
async store({request, response}) {
const profilePic = request.file('profile_pic', {
types: ['image'],
size: '60mb'
})
await profilePic.move(Helpers.tmpPath('uploads'), {
name: `${new Date().getTime()}.${file.subtype}`
})
if(!profilePic.moved()) {
return profilePic.error()
}
return 'File moved'
}
The size of image is 62,9 KB
@thetutlage I need to develop an important project using AdonisJS and I have a deadline, if you can help me in the shortest possible time, I would be immensely grateful
I tried your code and everything worked fine. Also the 60mb you have set is the current file max size. However you need to set the max payload size of request inside config/bodyParser.js file.
https://github.com/adonisjs/adonis-fullstack-app/blob/develop/config/bodyParser.js#L110
Also there was a typo that file.subtype has to be profilePic.subtype
The real problem is that the content-type defined in the request was like "application / x-www-form-urlencoded", by disabling this in Postman, it ran perfectly, thanks!
Ohhh yeah, it has to be multipart/form-data
hi, i have issue like this.
i tried upload pdf file (size 1-2Mb). the response always entity too large.
what can I do to solve the problem?
this is my code
const profilePic = request.file("profPic", {
types: ["image", "pdf"],
size: "5mb"
});
Hey @emjea! 馃憢
You need to increase the size limit in config/bodyParser.js.
Also, make sure that your proxy configuration let you upload a big file.
Hi @RomainLanz !
it's worked now.
Thanks so much :)
I have an issue but this time its from canvass dataURL. I already increase the limit to 100MB the error still display. I check the image size and its around 9KB only. Im using AJAX POST in submitting the data.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
Ohhh yeah, it has to be
multipart/form-data