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

Can I Suggest a Filename for Data: URI Downloads?

Linda Hamilton
Linda HamiltonOriginal
2024-12-16 02:23:13514browse

Can I Suggest a Filename for Data: URI Downloads?

specifying suggested filenames with data: URI

When using data: URI, the browser will prompt you to download a file consisting of the data held as base64 in the hyperlink itself. Is there any way of suggesting a default name in the markup? If not, is there a JavaScript solution?

Answer

Yes, you can use the download attribute to suggest a filename when using data: URI.

<a download='FileName' href='your_url'>

The download attribute is supported by Chrome, Firefox, Edge, Opera, desktop Safari 10 , iOS Safari 13 , but not IE11.

The above is the detailed content of Can I Suggest a Filename for Data: URI Downloads?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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