Renaming downloaded files using the download attribute of anchor HTML tag
Sometimes we need to adjust the file name that is going to be download by users. It may happen because the data source provides the file with strange names that sometimes is not friendly to users.
This file
renaming could be very simple implemented using the download attribute of <a>
tag. It could be utilized as in the example below:
<html>
<body>
<h1>Usage of download</h1>
<a href="https://www.w3.org/TR/CSS22/css2.pdf">CSS specification</a>
<br />
<a href="https://html.spec.whatwg.org/print.pdf" download="html_specification.pdf">
HTML specification - download with name "html_specification.pdf"
</a>
</body>
</html>
It is especially
useful when we are using web services that provides us the file content as a byte
stream, but without the proper formatting to be delivered to users.
You can see
a video class about this theme in the video below:
Comments
Post a Comment