From 79666a107719fcd26d4c3226b3c0344c62be8974 Mon Sep 17 00:00:00 2001 From: Arjun Krishna Date: Sun, 25 Apr 2021 05:09:32 +0530 Subject: [PATCH 1/3] File Upload Page - Design Complete: --- README.md | 10 +++---- public/img/file-icon.png | Bin 0 -> 1160 bytes public/stylesheets/style.css | 55 +++++++++++++++++++++++++++++++---- server.js | 4 +++ views/file-upload.hbs | 19 ++++++++++++ 5 files changed, 77 insertions(+), 11 deletions(-) create mode 100644 public/img/file-icon.png diff --git a/README.md b/README.md index 4e7a88b..85cb16e 100644 --- a/README.md +++ b/README.md @@ -12,11 +12,11 @@ Currently, its planned to be hosted locally (May change in the future) ## **How to contribute to the Project (Guidelines)** -- [ ] Fork the Repository to your account -- [ ] Clone it to Local Machine -- [ ] Start contributing to the project... -- [ ] Commit and Push it to your remote Repository -- [ ] Create a Pull Request towards this Main Repository +- [x] Fork the Repository to your account +- [x] Clone it to Local Machine +- [x] Start contributing to the project... +- [x] Commit and Push it to your remote Repository +- [x] Create a Pull Request towards this Main Repository **** diff --git a/public/img/file-icon.png b/public/img/file-icon.png new file mode 100644 index 0000000000000000000000000000000000000000..152862a0a2d4e4d6f2d9ddd1203ab1fef104fde5 GIT binary patch literal 1160 zcme7R@N?(olHy`uVBq!ia0y~yU~m9o4mJh`hEb%19`X({X(u#->!S7zpY!B zx9(r@AA_eC1rGQ`&u@IZ>A}bP#5J6Ik(iv2j(^t26hC&&gQq=SY}q zZL;~_^|im1j)`@uWk1+D_s`;a^qt+avV9@7Wo zhGMJ5O*7|J+LYmeJZb#DItb8lKF)^lIbUUWR~pc+T~rhUifi*z5|yMQf7 z_QA$&lk1<%@rq-5k<6#X#KGgn^!LGzH#zfn30-sOWM1^BCM&6{LyRG3nzpw-%hte0 z4J#tn>pg#M|NHPQ1J{i%ea}Bw_1?K)%4G8JDce0$rXR(#r%PKrm;bxI*g@jo9f6t5 zMlaVKd{DF#ef4S@n)XG--%S8v~LwoPnR-?SO58`%03!~O4sXf_Ek9uj*$w?ByGCDWFuJ?Yb z$>z41o9c{swXfefZ?a}iX2j`#Ng2u63!{|ZmR1~{bnkQTi;AgN8E2MUOSm(aJyGUB zj>F_g27Tjq=T@)bXtn3DoKoTb{CD(%xSMBhyh-sbfBTnfgQ;@kUk=r0*X{|+t}kGh z*|2unjOpwnR{Wtn6?`!qfg^^Kw85WHhtS;K_dzmy#;2#JE|plz`W)6`IN{atR8qvU!Adan zSgXYWz!=&8g#VM)37@virRVagi?Q>WnOF^YS0_kaYdVwMzOZQB1}g=PpB;8(5~rTM z`lT!Itbxg4-IL_@g*kfv#g%q5RLzx=zfrN{kGu52ZLT+_Yi!yVV92|gNr5$7UMpYx z6vG71K7NB`|M?P@Z)D{-!Ps!_MUNVcXO}oEdF{le)arwwxtgD zmvEkqWSI~m7%_uc * { +.row>* { padding-left: 0px; padding-right: 0px; } @@ -37,14 +49,45 @@ padding-right: 10px; padding-left: 10px; } + .search { margin-top: 15px; text-align: center; } - .home input { - border-radius: 50px; + + .hhh { + margin-bottom: 20px; + } + .icon img { + display: none; } - .home button { - border-radius: 50px; + .upload button { + width: 100%; + margin-top: 15px; + background-color: #271638; } - } \ No newline at end of file +} + +.dragNdrop { + border: 4px dashed rgba(255, 255, 255, 0.7); + width: 100%; + background: rgba(255, 255, 255, 0.3); + min-height: 100px; + height: 100%; + display: flex; + align-items: center; + justify-content: center; +} + +.title { + color: #271638; + padding: 15px; +} + +.browse { + text-decoration: underline; + cursor: pointer; +} + .upload button:hover { + background-color: #271638; + } \ No newline at end of file diff --git a/server.js b/server.js index 911a70d..c190114 100644 --- a/server.js +++ b/server.js @@ -19,4 +19,8 @@ app.get('/', (req, res) => { res.render('home'); }); +app.get('/upload', (req, res) => { + res.render('file-upload'); +}); + app.listen(3000); \ No newline at end of file diff --git a/views/file-upload.hbs b/views/file-upload.hbs index e69de29..47007ca 100644 --- a/views/file-upload.hbs +++ b/views/file-upload.hbs @@ -0,0 +1,19 @@ +
+
+
+
+
+
+ +
+
Drop your Files here or, browse
+
+
+
+ + + +
+
+
+
\ No newline at end of file -- knotmirror 0.0.1 From be46852f77646637ea762f92984589918dfabde8 Mon Sep 17 00:00:00 2001 From: Arjun Krishna Date: Sun, 25 Apr 2021 07:00:09 +0530 Subject: [PATCH 2/3] File Upload Page - File Upload --- public/stylesheets/style.css | 72 ++++++++++++++++++++++++------------ views/file-upload.hbs | 28 +++++++++++++- 2 files changed, 76 insertions(+), 24 deletions(-) diff --git a/public/stylesheets/style.css b/public/stylesheets/style.css index f9078be..e27e97f 100644 --- a/public/stylesheets/style.css +++ b/public/stylesheets/style.css @@ -44,6 +44,45 @@ padding-right: 0px; } +.dragNdrop { + border: 4px dashed rgba(255, 255, 255, 0.7); + width: 100%; + background: rgba(255, 255, 255, 0.3); + /* min-height: 100px; */ + height: 100%; + padding-top: 100px; + /* display: flex; */ + text-align: center; + /* justify-content: center; */ +} + +.dragNdrop input[type="file"] { + width: 320px; + margin-top: 15px; +} + +.dragged { + background: rgba(255, 255, 255, 0.5); +} + +.title { + color: #271638; + padding: 15px; +} + +.browse { + text-decoration: underline; + cursor: pointer; +} + +.upload button:hover { + background-color: #271638; +} + + + + + @media only screen and (max-width: 992px) { .col-lg-6 { padding-right: 10px; @@ -58,36 +97,23 @@ .hhh { margin-bottom: 20px; } - .icon img { + + .icon img, .title { display: none; } + .upload button { width: 100%; margin-top: 15px; background-color: #271638; } -} -.dragNdrop { - border: 4px dashed rgba(255, 255, 255, 0.7); - width: 100%; - background: rgba(255, 255, 255, 0.3); - min-height: 100px; - height: 100%; - display: flex; - align-items: center; - justify-content: center; -} - -.title { - color: #271638; - padding: 15px; -} + .dragNdrop { + width: 100%; + padding-top: 0px; + } -.browse { - text-decoration: underline; - cursor: pointer; + .dragNdrop input[type="file"] { + margin-top: 0px; + } } - .upload button:hover { - background-color: #271638; - } \ No newline at end of file diff --git a/views/file-upload.hbs b/views/file-upload.hbs index 47007ca..a70ea41 100644 --- a/views/file-upload.hbs +++ b/views/file-upload.hbs @@ -6,6 +6,7 @@
+
Drop your Files here or, browse
@@ -16,4 +17,29 @@ - \ No newline at end of file + + + \ No newline at end of file -- knotmirror 0.0.1 From 68bfa5a990ae7980e521fa98211eeed220dd6556 Mon Sep 17 00:00:00 2001 From: Arjun Krishna Date: Mon, 26 Apr 2021 03:16:00 +0530 Subject: [PATCH 3/3] Basic File Upload - Complete, Success Upload Page - Complete --- .gitignore | 3 +- package-lock.json | 29 ++++++++++++++++ package.json | 1 + public/stylesheets/style.css | 13 ++++++++ server.js | 16 +++++++++ views/file-upload.hbs | 64 +++++++++++++++++++----------------- views/upload-success.hbs | 33 +++++++++++++++++++ 7 files changed, 127 insertions(+), 32 deletions(-) create mode 100644 views/upload-success.hbs diff --git a/.gitignore b/.gitignore index b512c09..f2c50db 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -node_modules \ No newline at end of file +node_modules +uploads \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 4910df7..8a032cc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -148,6 +148,14 @@ "fill-range": "^7.0.1" } }, + "busboy": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/busboy/-/busboy-0.3.1.tgz", + "integrity": "sha512-y7tTxhGKXcyBxRKAni+awqx8uqaJKrSFSNFSeRG5CsWNdmy2BIK+6VGWEW7TZnIO/533mtMEA4rOevQV815YJw==", + "requires": { + "dicer": "0.3.0" + } + }, "bytes": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz", @@ -357,6 +365,14 @@ "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz", "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=" }, + "dicer": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/dicer/-/dicer-0.3.0.tgz", + "integrity": "sha512-MdceRRWqltEG2dZqO769g27N/3PXfcKl04VhYnBlo2YhH7zPi88VebsjTKclaOyiuMaGU72hTfw3VkUitGcVCA==", + "requires": { + "streamsearch": "0.1.2" + } + }, "dot-prop": { "version": "5.3.0", "resolved": "https://registry.npmjs.org/dot-prop/-/dot-prop-5.3.0.tgz", @@ -450,6 +466,14 @@ "vary": "~1.1.2" } }, + "express-fileupload": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/express-fileupload/-/express-fileupload-1.2.1.tgz", + "integrity": "sha512-fWPNAkBj+Azt9Itmcz/Reqdg3LeBfaXptDEev2JM8bCC0yDptglCnlizhf0YZauyU5X/g6v7v4Xxqhg8tmEfEA==", + "requires": { + "busboy": "^0.3.1" + } + }, "express-handlebars": { "version": "5.3.0", "resolved": "https://registry.npmjs.org/express-handlebars/-/express-handlebars-5.3.0.tgz", @@ -1181,6 +1205,11 @@ "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", "integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow=" }, + "streamsearch": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/streamsearch/-/streamsearch-0.1.2.tgz", + "integrity": "sha1-gIudDlb8Jz2Am6VzOOkpkZoanxo=" + }, "string-width": { "version": "4.2.2", "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.2.tgz", diff --git a/package.json b/package.json index e392415..daaf88a 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,7 @@ "homepage": "https://github.com/decoded-cipher/resource-server#readme", "dependencies": { "express": "^4.17.1", + "express-fileupload": "^1.2.1", "express-handlebars": "^5.3.0" }, "devDependencies": { diff --git a/public/stylesheets/style.css b/public/stylesheets/style.css index e27e97f..8ec417e 100644 --- a/public/stylesheets/style.css +++ b/public/stylesheets/style.css @@ -79,6 +79,19 @@ background-color: #271638; } +.check-img img{ + height: 100px; + width: auto; +} + +.links button { + margin: 10px; +} + +.links a :hover { + background-color: #271638; +} + diff --git a/server.js b/server.js index c190114..ca9160d 100644 --- a/server.js +++ b/server.js @@ -1,8 +1,10 @@ var express = require('express'); +var upload = require('express-fileupload'); var path = require('path'); var hbs = require('express-handlebars'); var app = express(); +app.use(upload()); app.set('views', (__dirname, 'views')); app.set('view engine', 'hbs'); @@ -23,4 +25,18 @@ app.get('/upload', (req, res) => { res.render('file-upload'); }); +app.post('/upload', (req, res) => { + if(req.files) { + // console.log(req.files); + + var file = req.files.file; + // console.log(file.name); + + file.mv('./uploads/' + file.name, (err) => { + // res.send('File Uploaded') + res.render('upload-success'); + }) + } +}) + app.listen(3000); \ No newline at end of file diff --git a/views/file-upload.hbs b/views/file-upload.hbs index a70ea41..ca96d08 100644 --- a/views/file-upload.hbs +++ b/views/file-upload.hbs @@ -1,45 +1,47 @@
-
-
-
-
- +
+
+
+
+
+ +
+ +
Drop your Files here or, browse
- -
Drop your Files here or, browse
+
+ + + +
-
- - - -
-
+
\ No newline at end of file diff --git a/views/upload-success.hbs b/views/upload-success.hbs new file mode 100644 index 0000000..0f9dc14 --- /dev/null +++ b/views/upload-success.hbs @@ -0,0 +1,33 @@ +
+
+
+
+ +
+

File Uploaded Successfully

+ +
+
+
+ + \ No newline at end of file -- knotmirror 0.0.1