Test upload常用的兩個方法
常常忘記,還是寫下來好了...
Step1: Configure your upload
Reference: https://github.com/expressjs/multer
Step2: Make a route for receive upload
Step3: Testing
Upload using curl:
Upload using upload form:
Step1: Configure your upload
Reference: https://github.com/expressjs/multer
Step2: Make a route for receive upload
router.post('/uploadtest', function(req, res, next) {
res.end('done...');
});
Step3: Testing
Upload using curl:
curl -F "image=@/Users/peihsinsu/Pictures/pic2.png" http://localhost:3000/uploadtest -X POST
Upload using upload form:
<form method="post" action="/uploadtest" name="submit" enctype="multipart/form-data">
<input type="file" name="fileField"><br /><br />
<input type="submit" name="submit" value="Submit">
</form>