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 7037529
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:33:23+00:00 2026-05-28T01:33:23+00:00

How does one go about naming files parsed by Formidable in Node? Currently my

  • 0

How does one go about naming files parsed by Formidable in Node? Currently my files are saving as ‘7c9d182a9892bb7588b49ea9d364efd0.pdf’, I would much prefer the original file names.

Anyone know how to do this?

  • 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-05-28T01:33:23+00:00Added an answer on May 28, 2026 at 1:33 am

    This is how I did it (check out the .on(file’…) function):

    // import required modules
        var express = require('express');
        var formidable = require("formidable"); // used for parsing form data
        var fs = require('fs');
    
    // prevent bodyParser from handling multipart forms (ie only handle get and post requests)
        delete express.bodyParser.parse['multipart/form-data'];
    
    // create server
        var app = express.createServer();
    
    // connect middleware
        app.configure(function() {
            // creates body object on request object
                app.use(express.bodyParser());
                app.use(express.methodOverride());
            // used to display static files such as css
                app.use(express.static(__dirname + '/static'));
        });
    
    // enable and define views
        app.set('views', __dirname + '/views');
        app.set('view engine', 'jade'); 
    
    //******************************
    //* create routes
    //******************************
    
    // file upload handling
        app.get('/photos/new', function(request, response) {
            response.render('photos/new');
        });
        app.post('/photos', function(request, response) {
            console.log('in /photos handler');
            var form = new formidable.IncomingForm();
    
            form.uploadDir = __dirname + '/static/upload/photos/';
    
            form.on('file', function(field, file) {
                //rename the incoming file to the file's name
                    fs.rename(file.path, form.uploadDir + "/" + file.name);
            });
    
            form.on('error', function(err) {
                console.log("an error has occured with form upload");
                console.log(err);
                request.resume();
            });
    
            form.on('aborted', function(err) {
                console.log("user aborted upload");
            });
    
            form.on('end', function() {
                console.log('-> upload done');
            });
    
            form.parse(request, function() {
                    response.render('photos/new');
            });
        });
    
    // start our server
        app.listen(8888);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How does one go about keeping track of source files, resources, references, assemblies, etc..
I just came across the following commit on GitHub: https://github.com/felixge/node-formidable/commit/0a0b150668daa3c6f01626d2565b898e5da12392 How does one go
How does one go about authoring a Regular Expression that matches against all strings
How does one go about referencing a class's static properties in xaml? In other
How does one go about programatically building a TemplateColumn object and adding it to
How does one go about changing the version information in a built binary? Specifically
How does one go about converting an image to black and white in PHP?
How does one go about establishing a CSS 'schema', or hierarchy, of general element
How does one go about attaching a bunch of code to an onkeydown event,
How does one go about catching exceptions from using controls in markup? For example,

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.