Home > Web Front-end > JS Tutorial > How Can I Suggest a Filename for Data: URI Downloads?

How Can I Suggest a Filename for Data: URI Downloads?

DDD
Release: 2024-11-27 21:20:10
Original
236 people have browsed it

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='>
Copy after login

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!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template