If a user clicks on a downloadable link such as
<a href="downloadable.txt">Download</a>
Is there a client-side (html or javascript) way to change the name of the file before the 'Save As' dialog?
To rename a file we have to create a new file and pass our new name to the File constructor. const myRenamedFile = new File([myFile], 'my-file-final-1-really. txt'); console.
Click on the "Edit Menu" > Preferences > General tab. Locate the "Save downloaded files to" section, Click on "Downloads" > "Other"... Browse and indicate your new download location.
slice(0, file. size, 'image/png'); newFile = new File([blob], 'name. png', {type: 'image/png'});
HTML5 provides the a[download]
attribute which lets you rename a file. This example will download link.txt
and rename it something.txt
.
<a download="something.txt" href="link.txt">asdf</a>
Note that this only works on same-origin URLs (i.e. not across different domains).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With