Skip to content

Eveningme/jquery-file-upload-middleware

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

jquery-file-upload-middleware

jQuery-File-Upload Express.js middleware. Based on the server code of jQuery-File-Upload

Usage:

    var express = require("express"),
        upload = require('jquery-file-upload-middleware');

    var app = express();
    app.configure(function () {
        ...
        app.use('/upload', upload({
            uploadDir: __dirname + '/public/uploads'
            tmpDir: '/tmp',
            maxPostSize: 11000000000, // 11 GB
            minFileSize: 1,
            maxFileSize: 10000000000, // 10 GB
            acceptFileTypes: /.+/i,
            // Files not matched by this regular expression force a download dialog,
            // to prevent executing any scripts in the context of the service domain:
            safeFileTypes: /\.(gif|jpe?g|png)$/i,
            imageTypes: /\.(gif|jpe?g|png)$/i,
            imageVersions: {
                'thumbnail': {
                    width: 80,
                    height: 80
                }
            },
            accessControl: {
                allowOrigin: '*',
                allowMethods: 'OPTIONS, HEAD, GET, POST, PUT, DELETE'
            }
        }));
        app.use(express.bodyParser());
        ...
    });

On the frontend:

   <input id="fileupload" type="file" name="files[]" data-url="/upload" multiple>
   <script>$('#fileupload').fileupload({ dataType: 'json' })</script>

License

Copyright (c) 2012 Aleksandr Guidrevitch Released under the MIT license.

About

jQuery-File-Upload Express.js middleware

Resources

Stars

Watchers

Forks

Packages

No packages published