Answer the question
In order to leave comments, you need to log in
How to upload a file correctly?
I don’t understand what the problem is when uploading a file, in particular, the problem with mobile devices.
There is a form on the site, using js I send the document id to search for the file and follow up with it.
In the handler, I reduce and crop the image
function resize(s, w) {
gm(
path.image // путь до изображения
)
.resize(s.w, s.h, '^')
.gravity('Center')
.crop(s.w, s.h)
.quality(90)
.noProfile()
.toBuffer(function (e, buffer) {
return c(e, buffer);
});
}
res.statusCode = 200;
res.setHeader('content-type', 'image/jpeg');
res.setHeader('Content-Disposition', 'attachment; filename=' + data.get.image); // название картинки вместе с расширением
res.end(buffer);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question