-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupload.js
More file actions
47 lines (42 loc) · 1.47 KB
/
upload.js
File metadata and controls
47 lines (42 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
const express = require('express');
const multer = require('multer');
const path = require('path');
const fs = require('fs');
const app = express();
const upload = multer({ dest: 'Resumes/' });
app.get('/', (req, res) => {
res.sendFile(path.join(__dirname, 'index.html'));
});
app.post('/upload', upload.single('pdfFile'), (req, res) => {
const file = req.file;
if (!file) {
return res.status(400).send('No file uploaded.');
}
const fileName = file.originalname;
const filePath = path.join(__dirname, 'Resumes', fileName);
fs.renameSync(file.path, filePath);
const fileInfo = {
path: filePath,
name: fileName
};
// Save the fileInfo object to a JSON file
fs.writeFile('Resumes/file_info.json', JSON.stringify(fileInfo), (err) => {
if (err) throw err;
console.log('File info saved!');
});
res.type('text/html').send(`
File uploaded successfully! You will be redirected in <span id="countdown">5</span> seconds.
<script>
var count = 5;
setInterval(function() {
count--;
document.getElementById('countdown').innerHTML = count;
if (count == 0) {
window.location.href = "http://localhost:63342/New%20folder/DH2023/processed_resume_review.html"; // Replace "/" with the URL of your desired redirect page
}
}, 1000);
</script>
`);});
app.listen(3000, () => {
console.log('Server listening on port 3000');
});