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

153
Vistas
ask user to write file name before downloading txt file in angular

I am trying to download content in a txt file. belwo is the sample code

download() {
let content = "Sample text";
saveAs(new Blob([content], { type: 'text/plain'}), 'sample.txt');

I am using file-saver lib to downlaod the content. all works fine but i need to open the browser popup where user can write/override the file name before downloading it and choose the directory as well where user will save the file.

Any help here will be highly appreciated.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Before directly calling the saveAs() function upon click of the button to download the content, probably you can call a prompt to get the name, and then resume the rest.

download() {
    let filename = window.prompt('Please enter a name for your file', 'sample');
    let content = "Sample text";
    saveAs(new Blob([content], { type: 'text/plain'}), `${filename}.txt`);
}

Or to be more stylish, if you use Bootstrap, you can make use of modals, or any stylish modal of your own.

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