Unable to download file via HTML5's download attribute
P粉642919823
P粉642919823 2023-09-02 21:11:35
0
1
488
<p>I'm trying to create a download link the way I've been doing it before. But now it keeps redirecting me to Google Docs - I've never encountered this before and it should be a simple task, so this is quite shocking to me. </p> <p>I used the HTML5 download attribute: </p> <pre class="brush:php;toolbar:false;"><a href="../files/uploads/myfile.docx" download>myfile.docx</a></pre> <p>But I always get redirected to Google Docs. I also opened the Chrome Developer Console and noticed that after I clicked on the link, it changed the href to Google Docs. I have absolutely no idea why this is happening. </p> <p>The path should be fine, I can't figure out the problem. what do I do? </p>
P粉642919823
P粉642919823

reply all(1)
P粉513318114

The download attribute only applies to same-origin URLs. So if the href is different from the site's source, it won't work. In other words, you can only download files that belong to that website. This attribute follows the same rules outlined in the Same Origin Policy

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template