VARCHAR
datatype instead of any BLOB
or other binary
datatype.harddisk
in possible image space
/public/images/
i am new to express .
Any sample example to achieve this ?
What you can do is use the multipart
middleware, which automatically streams the file uploads to the disk, and then provides a req.files
object.
app.use('/upload', express.multipart({ uploadDir: '/public/images' }));
Once you've configured this, in your request handler, you can get the upload path (see multiparty's documentation, which is used internally by the multipart
middleware):
app.post('/upload', function (req, res, next) {
// Assuming the field name of the file in the form is 'file'
var path = req.files.file.path;
connection.query('your mysql query', next);
});