Skip to content

Commit

Permalink
check for file error
Browse files Browse the repository at this point in the history
  • Loading branch information
valmassoi committed Apr 28, 2016
1 parent 3ed613f commit 7f91805
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,15 @@ app.get('/', (req, res) => {
res.sendFile('/public/index.html')
})
app.post('/uploads', upload.single('file'), (req, res) => {
console.log(req.file)
res.json({
name: req.file.originalname,
size: req.file.size
})
clearUploads()
if (req.file){
res.json({
name: req.file.originalname,
size: req.file.size
})
clearUploads()
}
else
res.json({ error: "No file to upload, please browse for a file first." })
})

app.get("*", (req, res) => {
Expand Down

0 comments on commit 7f91805

Please sign in to comment.