Answer the question
In order to leave comments, you need to log in
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
Check also the express settings that are written here stackoverflow.com/questions/21128451/express-cant-...
Make sure that uploadDir has write permissions.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question