So I am following this tutorial: http://thejackalofjavascript.com/uploading-files-made-fun/
I have followed the steps all the way up to where they create the routes and haven't actually created any views. It says
Thats it we are all done with our server. Restart your server and navigate to
http://localhost:3000/upload
. You should see a JSON response with the empty array of files.
However when I try to run app.js it sits for a few seconds and then just goes back to the command prompt. No errors are given and I am clueless as to how to fix this.
Here is my code in routes/uploadManager.js
var options = {
tmpDir: __dirname + '/../public/uploaded/tmp',
uploadDir: __dirname + '/../public/uploaded/files',
uploadUrl: '/uploaded/files/',
maxPostSize: 11000000000, // 11 GB
minFileSize: 1,
maxFileSize: 10000000000, // 10 GB
acceptFileTypes: /.+/i,
// Files not matched by this regular expression force a download dialog,
// to prevent executing any scripts in the context of the service domain:
inlineFileTypes: /\.(gif|jpe?g|png)/i,
imageTypes: /\.(gif|jpe?g|png)/i,
imageVersions: {
width: 80,
height: 80
},
accessControl: {
allowOrigin: '*',
allowMethods: 'OPTIONS, HEAD, GET, POST, PUT, DELETE',
allowHeaders: 'Content-Type, Content-Range, Content-Disposition'
},
storage : {
type : 'local'
}
};
var uploader = require('blueimp-file-upload-expressjs')(options);
module.exports = function (router) {
router.get('/upload', function (req, res) {
uploader.get(req, res, function (obj) {
res.send(JSON.stringify(obj));
});
});
router.post('/upload', function (req, res) {
uploader.post(req, res, function (obj) {
res.send(JSON.stringify(obj));
});
});
router.delete('/uploaded/files/:name', function (req, res) {
uploader.delete(req, res, function (obj) {
res.send(JSON.stringify(obj));
});
});
return router;
}
I apologize. I was trying to run node app.js
when I was supposed to be running node bin/www
since this is an express.js app.