Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

151
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!