I've wrote an example to upload a file using nodejs based on tutorials found online, here's what I have now :
index.html
:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Simple Multer Upload Example</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<form action="/" enctype="multipart/form-data" method="post">
<input type="file" name="file-to-upload">
<input type="submit" value="Upload">
</form>
</body>
</html>
and the app.js
:
const express = require('express');
const multer = require('multer');
const path = require('path')
// init app
const app = express();
// set storage
var storage = multer.diskStorage({
destination: 'uploads',
filename: function(req,file,cb){
cb(null,'MYONE'+path.extname(file.originalname));
}
}
)
var upload = multer({ storage: storage })
app.get('/', (req, res) => {
res.sendFile(__dirname + '/index.html');
});
// It's very crucial that the file name matches the name attribute in your html
app.post('/', upload.single('file-to-upload'), (req, res) => {
res.redirect('/');
});
app.listen(3000);
my question is, is there a way to merge both buttons in one select/upload?
thanks in advance for any hint !