Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

1.3K
Vistas
Get full file path in Node.js

I have an application which uploads csv file into a particular folder, say, "uploads". Now I want to get the full path of that csv file, for example, D:\MyNodeApp\uploads\Test.csv.

How do I get the file location in Node.js? I used multer to upload file.

over 4 years ago · Santiago Trujillo
3 Respuestas
Responde la pregunta

0

var path = require("path");
var absolutePath = path.resolve("Relative file path");

You dir structure for example:

C:->WebServer->Public->Uploads->MyFile.csv

and your working directory would be Public for example, path.resolve would be like that.

path.resolve("./Uploads/MyFile.csv");

POSIX home/WebServer/Public/Uploads/MyFile.csv
WINDOWS C:\WebServer\Public\Uploads\MyFile.csv

this solution is multiplatform and allows your application to work on both windows and posix machines.

over 4 years ago · Santiago Trujillo Denunciar

0

Get all files from folder and print each file description.

const path = require( "path" );
const fs = require( 'fs' );
const log = console.log;
const folder = './';

fs.readdirSync( folder ).forEach( file => {
   
   const extname = path.extname( file );
   const filename = path.basename( file, extname );
   const absolutePath = path.resolve( folder, file );

   log( "File : ", file );
   log( "filename : ", filename );
   log( "extname : ", extname );
   log( "absolutePath : ", absolutePath);

});
over 4 years ago · Santiago Trujillo Denunciar

0

Assuming you are using multer with express, try this in your controller method:

var path = require('path');

//gets your app's root path
var root = path.dirname(require.main.filename)

// joins uploaded file path with root. replace filename with your input field name
var absolutePath = path.join(root,req.files['filename'].path) 
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda