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

527
Views
How to specify the filename during download over HTTP

I currently store my woocommerce product files on S3 in the following format:

/bucket/{product_id}.zip

When a customer clicks the download link in their customer dashboard the element is as follows:

<a href="https://url/1234.zip">Download Product Name</a>

This downloads the file into their downloads folder as 1234.zip

I would like to be able to pass some values to the request so that the filename can be downloaded as {param1}-{param2}.zip

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

Like this:

<a href="https://url/1234.zip" download=`${param1}-${param2}.zip`>Download Product Name</a>

Refer: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attr-download

Note:

download only works for same-origin URLs, or the blob: and data: schemes. How browsers treat downloads varies by browser, user settings, and other factors. The user may be prompted before a download starts, or the file may be saved automatically, or it may open automatically, either in an external application or in the browser itself. If the Content-Disposition header has different information from the download attribute, resulting behavior may differ: If the header specifies a filename, it takes priority over a filename specified in the download attribute. If the header specifies a disposition of inline, Chrome and Firefox prioritize the attribute and treat it as a download. Old Firefox versions (before 82) prioritize the header and will display the content inline.

over 4 years ago · Santiago Trujillo Report

0

When they click a button to download the file, you can add the HTML5 attribute "download" where you can set the default filename.

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attr-download

<a href="https://url/1234.zip" download={${param1}-${param2}.zip}>Download Product Name

over 4 years ago · Santiago Trujillo 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!