master
Selcuk Sari 4 years ago
parent 679934a90a
commit 233c5b8ff5

@ -127,4 +127,6 @@ dist
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
.pnp.*
public/upload/raw

@ -9,6 +9,7 @@
"version": "1.0.0",
"license": "ISC",
"dependencies": {
"cors": "^2.8.5",
"express": "^4.18.1",
"express-fileupload": "^1.4.0",
"fs": "^0.0.1-security",
@ -580,6 +581,18 @@
"resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz",
"integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ=="
},
"node_modules/cors": {
"version": "2.8.5",
"resolved": "https://registry.npmjs.org/cors/-/cors-2.8.5.tgz",
"integrity": "sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==",
"dependencies": {
"object-assign": "^4",
"vary": "^1"
},
"engines": {
"node": ">= 0.10"
}
},
"node_modules/crypto-random-string": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/crypto-random-string/-/crypto-random-string-2.0.0.tgz",
@ -2878,6 +2891,15 @@
"resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz",
"integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ=="
},
"cors": {
"version": "2.8.5",
"resolved": "https://registry.npmjs.org/cors/-/cors-2.8.5.tgz",
"integrity": "sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==",
"requires": {
"object-assign": "^4",
"vary": "^1"
}
},
"crypto-random-string": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/crypto-random-string/-/crypto-random-string-2.0.0.tgz",

@ -10,6 +10,7 @@
"author": "Selcuk Sari",
"license": "ISC",
"dependencies": {
"cors": "^2.8.5",
"express": "^4.18.1",
"express-fileupload": "^1.4.0",
"fs": "^0.0.1-security",

@ -20,6 +20,9 @@ function submitForm(e) {
for (let i = 0; i < imgFiles.files.length; i++) {
formData.append("files", imgFiles.files[i]);
}
for (key in formData.keys()) {
console.log(key);
}
fetch("http://localhost:3000/invoice_sign/upload_files", {
method: "POST",
body: formData,

@ -128,14 +128,25 @@ router.get("/download", function (req, res) {
});
const multer = require("multer");
const upload = multer({ dest: "./public/upload/raw" });
// router.use(express.json());
// router.use(express.urlencoded({ extended: true }));
const fileStorageEngine = multer.diskStorage({
destination: (req, file, cb) => {
cb(null, "./public/upload/raw");
},
filename: (req, file, cb) => {
const fileName = decodeURI(file.originalname);
console.log(fileName);
cb(null, fileName);
},
});
const upload = multer({ storage: fileStorageEngine });
router.post("/upload_files", upload.array("files"), uploadFiles);
function uploadFiles(req, res, next) {
console.log(req.body);
console.log(req.files);
function uploadFiles(req, res) {
// console.log(req.body);
// console.log(req.files);
// console.log(req.files[0].toString("latin1"));
res.setHeader("Access-Control-Allow-Origin", "*");
res.json({ message: "Successfully uploaded files" });
}

@ -5,6 +5,8 @@ block content
.row
.col-sm-8
h3 Invoice Signer
.progress
.progress-bar.progress-bar-animated.progress-bar-striped(role="progressbar",aria-valuenow="30",aria-valuemin="0",aria-valuemax="100",style="width: 25%")
form#form
.m-3
label.form-label.file-upload-wrapper(for='formFile') Choose a file to embed an image

Loading…
Cancel
Save