forked from richardgirges/express-fileupload
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removed coffeescript completely. Added test directory with sample exp…
…ress app. TODO: write proper unit tests
- Loading branch information
Richard Girges
committed
Apr 22, 2016
1 parent
ca393f0
commit f1d3c69
Showing
5 changed files
with
56 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,4 @@ Desktop.ini | |
node_modules | ||
*.log | ||
*.gz | ||
test/uploadedfiles |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<html> | ||
<body> | ||
<form ref='uploadForm' | ||
id='uploadForm' | ||
action='http://localhost:8000/upload' | ||
method='post' | ||
encType="multipart/form-data"> | ||
<input type="file" name="sampleFile" /> | ||
<input type='submit' value='Upload!' /> | ||
</form> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
var express = require('express'), | ||
fileUpload = require('../lib/index.js'), | ||
app = express(); | ||
|
||
app.use('/form', express.static(__dirname + '/upload.test.html')); | ||
|
||
// default options | ||
app.use(fileUpload()); | ||
|
||
app.get('/ping', function(req, res) { | ||
res.send('pong'); | ||
}); | ||
|
||
app.post('/upload', function(req, res) { | ||
var sampleFile, uploadPath; | ||
|
||
if (!req.files) { | ||
res.status(400).send('No files were uploaded.'); | ||
return; | ||
} | ||
|
||
sampleFile = req.files.sampleFile; | ||
|
||
uploadPath = __dirname + '/uploadedfiles/' + sampleFile.name; | ||
|
||
sampleFile.mv(uploadPath, function(err) { | ||
if (err) { | ||
res.status(500).send(err); | ||
} | ||
else { | ||
res.send('File uploaded to ' + uploadPath); | ||
} | ||
}); | ||
}); | ||
|
||
app.listen(8000, function() { | ||
console.log('Express server listening on port 8000'); | ||
}) |