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

168
Vistas
How would I edit a particular file with js

I want to edit and read a file using JavaScript using the FileReader API. However, all the tutorials I have found ask me to specify the file parameter using the value from <input type="file">. Would I be able to set the file parameter as a file address like 'C:/Users/Code/example.txt'.

FileReader API:

 function printFile(file) {
  const reader = new FileReader();
  reader.onload = function(evt) {
    console.log(evt.target.result);
  };
  reader.readAsText(file);
}
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Due to security concerns, you cannot do this in the user's browser, unless the user is uploading. Here is a question that helps you read the file when the user selects it to upload: get the data of uploaded file in javascript

It is however, possible on the server side using nodejs. Here is a sample code that does that on the server side:

const fs = require('fs')

fs.readFile('/Users/joe/test.txt', 'utf8' , (err, data) => {
  if (err) {
    console.error(err)
    return
  }
  console.log(data)
})
about 4 years ago · Juan Pablo Isaza 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