Giter Club home page Giter Club logo

express-upload's People

Contributors

jonjenkins avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

express-upload's Issues

req.files is undefined

I've tried numbers of times, but the result of
console.log(req.body);
console.log(req.files);
is:
{}
undefined

if I remove the
enctype="multipart/form-data"
of the form,
console.log(req.body);
console.log(req.files);
is
{ thumbnail: 'w.txt' }
undefined

(thumbnail is the name of the input file element)

what I'm using is
Windows OS nodejs 0.10.24
express 3.4.8
and have tried express 3.5.4
and ejs module

Do you think that's the problem of the version?
Do you think that's the problem of the unicode?(I'm using UTF-8)
Do you think there're still some error in the code?

Thank you very much for you help!

Upload security

Multer uploads all files in the POST request to the uploads directory, regardless of what the variable is called. This means you can sneak files onto the server just by POSTing them with a different variable name. You can do with without error on the server side by uploading a valid file along with an invalid one.

This will also happen for any other POST request you can make to the server (even if the route is not meant to handle file uploads), which although is not an issue for this example it will be an issue for any application that handles other POST requests.

Not sure of the best way to handle it, but firstly using a explicit path when you use the multer middleware would stop the second issue:

app.configure(function () {
    app.use('/api/upload', multer({
        ...

Then multer should only handle file uplaods from routes that you are expecting to handle file uploads.

Then you must deal with other files explicitly, either by looping over all the files in req.files or by rejecting files that are not inside your expected variable which could possibly be done with onFileUploadStart().

I know that these are not real issues for this example as it is only an example. But people copying this will probably not be aware of any of these issues (I am struggling to find any example that even mentions any of these issues, which is a little worrying).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.