myfile.docx but I always get redirected to G"> Unable to download file via HTML5's download attribute-PHP Chinese Network Q&A
Unable to download file via HTML5's download attribute
P粉642919823
P粉642919823 2023-09-02 21:11:35
0
1
370

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.

I used the HTML5 download attribute:

myfile.docx

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.

The path should be fine, I can't figure out the problem. what do I do?

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
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!