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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T15:01:30+00:00 2026-06-17T15:01:30+00:00

So, I have been working on an upload script (code is below) that I

  • 0

So, I have been working on an upload script (code is below) that I have working on my windows machine, but on my Linux server it seems to fail with

Error: ENOENT, open 'uploads/da5ab67b48ea2deecd25127186017083'

I understand that the error is saying there is no path/file, but I do check to for file existence before I attempt the file rename.

exports.product_files_upload = function (req, res) {
    if (req.files) {
        var tmpArray = [];
        for(var file in req.files){
            console.log(file)
            if (file){
                var splitName = file.split('-');
                if (splitName.length > 1) {
                    var username = splitName[0];
                    var productId = splitName[1];
                    var index = splitName[2];
                } else {
                    return;
                }
            } else {
                return;
            }
            //console.log(username)
            //console.log(productId)
            var tmp_path = req.files[file].path;
            console.log(fs.existsSync(tmp_path))
            createUserDir();
            createProductDirs(username, productId);
            //console.log(__dirname)
            var target_path = './public/user_files/'+ username + '/products/'+productId+'/files/' + req.files[file].name,
                save_path = 'user_files/'+ username + '/products/'+productId+'/files/' + req.files[file].name;
            if (fs.existsSync(target_path)) {
                tmpArray.push({exists:true, name:req.files[file].name});
            } else {
                tmpArray.push({
                    size: req.files[file].size,
                    type: req.files[file].type,
                    name: req.files[file].name,
                    path: save_path,
                    exists:false
                });
                if (fs.existsSync(tmp_path)) {
                    fs.rename(tmp_path, target_path, function(err) {
                        if (err) throw err;
                        // delete the temporary file, so that the explicitly set temporary upload dir does not get filled with unwanted files
                        fs.unlink(tmp_path, function() {
                            if (err) throw err;
        //                    res.send(save_path);

                        });
                    });
                } else {
                    tmpArray.push({
                        size: req.files[file].size,
                        type: req.files[file].type,
                        name: req.files[file].name,
                        path: save_path,
                        exists:false
                    });
                }
            }
        }
        res.json(tmpArray);
    }

};

UPDATE: I am using forever for running my express app, and when I stopped my app forever process and switched to just “node app.js” the problem was fixed. This is not an acceptable fix. I am thinking there might be a problem with forever.

  • 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-17T15:01:32+00:00Added an answer on June 17, 2026 at 3:01 pm

    Okay, I figured it out. I was using forever with an absolute path to launch my app on my linux box like

    forever start /path/to/app.js
    

    But when I cd into the app directory and then launch the app it works.

    forever start app.js
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been working on a upload file that works fine on localhost (windows)
I have been working in a Perl script to read log files, but none
I have been working with SQL Server as a Developer a while. One thing
I have been working on a project on and off, but I haven't touched
I have been working with NSArray s and NSMutableArray s that store NSDate objects
I have been working on an iPhone app that has a feature of uploading
I have been working on making a form that uploads an image through ajax
I have been working with ExpressJS to facilitate file uploads, but as far as
I have been struggling for days to get a working upload onto the admin
I have been working on an app that takes screen shots, kinda like http://puush.me/

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.