fileup-node

File upload helper for Nodejs/Express

npm install fileup-node
6 downloads in the last week
25 downloads in the last month

fileup-node

File upload helper for nodejs/express

Install

$ npm install fileup-node
POST your file to /doupl

Upload using HTML

<form method="post" enctype="multipart/form-data" action="/doupl">
    <input type="file" name="myfile">
    <input type="submit">
</form>

Upload using curl

$ curl -F myfile=@<filename> localhost/doupl

This can be used for other web servers, that support app.post(req, res)

Example app (Express)

var express = require('express'), app = express();
app.use(express.bodyParser());

require('./fileup-node.js')('./testdir', app, function(r, s){
    // after file has been uploaded and saved
    s.end(r.files.myfile.name + ' has been uploaded');
})

app.get('/', function(r, s){
    s.setHeader('Content-Type', 'text/html');
    s.end('\
        <form method="post" enctype="multipart/form-data" action="/doupl">\
            <input type="file" name="myfile">\
            <input type="submit">\
        </form>');
})

app.listen(80);
npm loves you