File tree 1 file changed +32
-0
lines changed
1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -45,6 +45,38 @@ On the frontend:
45
45
<script >$ (' #fileupload' ).fileupload ({ dataType: ' json' }) </script >
46
46
```
47
47
48
+ To prevent access to /upload except for post (for security)
49
+ ``` javascript
50
+ upload .configure ({
51
+ uploadDir: __dirname + ' /public/uploads/' ,
52
+ uploadUrl: ' /uploads'
53
+ });
54
+
55
+ // / Redirect all to home except post
56
+ app .get (' /upload' , function ( req , res ){
57
+ res .redirect (' /' );
58
+ });
59
+
60
+ app .put (' /upload' , function ( req , res ){
61
+ res .redirect (' /' );
62
+ });
63
+
64
+ app .delete (' /upload' , function ( req , res ){
65
+ res .redirect (' /' );
66
+ });
67
+
68
+ app .use (' /upload' , function (req , res , next ){
69
+ upload .fileHandler ({
70
+ uploadDir : function () {
71
+ return __dirname + ' /public/uploads/'
72
+ },
73
+ uploadUrl : function () {
74
+ return ' /uploads'
75
+ }
76
+ })(req, res, next);
77
+ });
78
+ ```
79
+
48
80
Overriding global configuration
49
81
50
82
``` javascript
You can’t perform that action at this time.
0 commit comments