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

512
Views
html/js how to ask the user where to download a file

I would like to make an html file that contains a button that when clicked, asks the user where to download a js generated file to. For example, here is a screenshot of my firefox browser prompting me to decide where I want to save a file I am about to download off a webpage.

example

Currently my solution is the following code:

<script>
    function download(filename, text){
        let element = document.createElement('a')
        element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text))
        element.setAttribute('download', filename)
        element.click()
    }

    download("hello.txt","This is the content")

</script>

However the popup does not ask where to save the file to as seen here:

enter image description here

How can I replicate the first situation with JS and HTML?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

This depends entirely on the browser's implementation and is not something you can control with Javascript.

In this case the user would have to select save file.

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!