I'm using Node.js/Express and submitting an image to the server from a webpage via AJAX. The image has been processed and cropped, so I'm using the resultant dataURL and sending it to my server by a post request like this. The dataURL is completely good and accurate and contains the image as it should. So I simply send it to the server.
var fd = new FormData();
fd.append('dataURL',dataURL);
console.log('dataURL length:',dataURL.length);
$.ajax({
type: "POST",
url: `/pwa/update-attachment`,
data: fd,
contentType: false,
processData: false,
success: function(result)
{
}
});
On the server side there are no errors but the dataURL parameters is truncated to 1mb. For reference, my server is setup to accept multipart form data using using bodyparser as follows. I tried using size limits with bodyParser (either high or low) and neither seem to take effect in this case.
const bodyParser = require('body-parser');
app.use(bodyParser.urlencoded({extended: false })); // support encoded bodies
I receive my post like this:
router.post('/update-attachment',(req,res) => {
console.log('dataurl:',req.body.dataURL.length);
...
});
The dataURL is truncated to 1048576 bytes. Works perfectly fine for smaller images.