Home >Web Front-end >JS Tutorial >How Can I Suggest a Filename for Data: URI Downloads?
Providing a Suggested Filename for Data: URI Downloads
When using data: URI to download data as a file, the browser typically generates a generic filename. However, it is often desirable to specify a suggested filename to the user for convenience.
Default Name Suggestion with the download Attribute
The HTML download attribute provides a solution for suggesting a default filename for data: URI downloads:
<a download='FileName' href='data:application/octet-stream;base64,SGVsbG8='>
This attribute works on most modern browsers, including Chrome, Firefox, Edge, Opera, desktop Safari 10 , iOS Safari 13 , and excludes IE11. When the user clicks the anchor tag, the browser will suggest the specified FileName as the default download name.
The above is the detailed content of How Can I Suggest a Filename for Data: URI Downloads?. For more information, please follow other related articles on the PHP Chinese website!