Here is the html:
<!DOCTYPE HTML>
<html>
<body>
<a href = "img/test.txt" download> Download </a>
</body>
</html>
This identifies the file that I am trying to download, but instead of downloading it like I expect the "download" attribute to do, it just redirects to the txt file within the browser. What am I doing wrong here?
This is how you download the file, (React env, as you mentioned in the chat)
import txtFile from '<path_to_txt_file>'; // putting this inside the React component <a href={txtFile} download="txtFile.txt"> Download Here </a>;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.