Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

176
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda