Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8357271
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T10:25:35+00:00 2026-06-09T10:25:35+00:00

Working with expressjs for about a month by now I have stumbled across the

  • 0

Working with expressjs for about a month by now I have stumbled across the problem of file uploads. Despite consulting Google & various blogs I have failed finding an answer to the following three questions:

What do I have to do / what settings for bodyParser do I have to choose in order to:

  1. Make sure there was indeed a file uploaded (currently, when submitting the form without choosing a file an empty file gets created).

  2. Where can I specify a value for the maxium size a file is allowed to have?

  3. How can I omit the renaming of the file?

Currently I am including bodyParser in my express (v. 3.0.0) app with the following option:

{keepExtensions: true, uploadDir: __dirname + '/public/uploads'}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T10:25:36+00:00Added an answer on June 9, 2026 at 10:25 am

    I recently ran into a similar problem.
    for Question #2, check http://www.senchalabs.org/connect/middleware-limit.html

    app.use(express.limit('4M')); // in your app.configure()

    app.post('/upload', function(req, res) {
        var fs = require('fs'),
            file = req.files.myfile; //your file field;
    
    
        if(file.size === 0) { // question #1
            fs.unlinkSync(file.path);
            res.redirect('/error?');
        } else { //question #3
            var fn = file.path.split('/');
            fs.rename(file.path, file.path.replace(fn[fn.length-1], file.name));
            res.redirect('/success?');
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an expressjs app with everyauth setup. Everyauth is working fine. Now, I
i have problem with my map. Map was working correctly about 5 months ago.
have been working and wearing out my fingers doing google searches with this one:
I am working on WPF application, and now I have to choose which database
Have successfully gotten the csrf middleware working in express as per previous SO questions.
I'm confused about getting Qt working with Visual Studio Express. Most of the searches
I have a working installation of mssql, php on Windows 2003, SQL Server 2008
I'm working in Microsoft Visual C# 2008 Express. Let's say I have a string
I have a basic question about Bayesian networks. Let's assume we have an engine,
So. I have got web-chat working on socket.io. I'm thinking of using it also

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.