D
D
Dmitry Demin2014-04-08 19:04:33
JavaScript
Dmitry Demin, 2014-04-08 19:04:33

Express and Upload files. Why are the files not uploading?

Hello ladies and gentlemen. Almost the whole essence of the problem is reflected in the title, however, I dare to add that there was no error or anything that you can grab onto and quickly run to google.
The files just don't exist.
Situation: I have a standard Express application with a few
app.js changes:
app.use(express.bodyParser({ keepExtensions: true, uploadDir: './uploads' }));
app.get('/', routes.index);
app.post('/upload', routes.upload);
routes/index.js:
exports.index = function(req, res){
res.render('index', { title: 'UploadService',user:'User' });
};
exports.upload = function(req, res){
if (!!req.files)
res.
else
res.send('Not ok');
};
views/index.jade:
h1 Welcome, #{user}!
p Here you can upload your files!
form(method='POST',name='Form',action='/upload')
input(type='file',name='myfiles',multiple)
input(type='submit')
Judging by stable response " Not ok" I dare to assume that the files were simply not delivered.
Perhaps the files are not sent due to the fact that I run the server locally, but I am not inclined to think so, because there were no problems when working with apache.
I beg you, oh gods of programming, help your servant figure it out.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vit, 2014-04-09
@keksmen

Check also the express settings that are written here stackoverflow.com/questions/21128451/express-cant-...
Make sure that uploadDir has write permissions.

V
Vit, 2014-04-08
@fornit1917

Maybe it's because the form doesn't have enctype="multipart/form-data" set?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question