6

so i have this problem with hyperlink attribute download. basically i have link that download a certain file. however it doesnt work..

<a href="somelink/somefile.txt" download="" class="external">download file</a>

With this format, it will download the file but it will give me an failed file says 'no file'.

On the other hand if i have link that has a complete uri format:

<a href="http://wwww.somesite.com/somelink/somefile.txt" download="" class="external">download file</a>

It redirects me to the page and it will just show the file. The weird thing is when I tried it on mozilla and brave browser. it works. but in safari, and my default is google chrome. its not working..

Am I missing something? maybe in my header? really appreciate if you can help.. thanks!

EDITED

also, i've read this stuff about content disposition, so how do i know that my webpage set as inline for that matter. enter image description here

Jarvis Millan
  • 451
  • 1
  • 7
  • 19
  • It seems like you have tow problem. one is the relative path could not found file. the other is the browser support about link download attribute. – 鄭元傑 May 22 '18 at 02:37
  • Possible duplicate of [Chrome Download Attribute not working](https://stackoverflow.com/questions/23872902/chrome-download-attribute-not-working) – Muhammad May 22 '18 at 02:38
  • i am looking for solution. the answer didnt give solution just found out. – Jarvis Millan May 22 '18 at 02:45
  • https://stackoverflow.com/a/23873370/6545866, a content disposition but see my edited question, i asked if how do you know if you enabled it or if you set to inline – Jarvis Millan May 22 '18 at 02:46

3 Answers3

7

it turns out, my problem is conflicted by same origin urls. Apprently, I am rquesting from different hosts/site, for further explanation see : https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy

Jarvis Millan
  • 451
  • 1
  • 7
  • 19
1

If you look at here https://www.w3schools.com/TagS/tag_a.asp

Scroll down to attributes, and you will see that the DOWNLOAD attribute is only supported by HTML5, which, as it seems, your friend's version of Safari does not support. I recommend updating the program.

Alternatively, you can right-click on the download link, then click Save As..., then download it that way.

Sudhir Ojha
  • 3,247
  • 3
  • 14
  • 24
0

This may also be caused js intercepting navigation and redirecting. If so, you may be able to work around it by adding a target attribute.

<a href="file.txt" download target="_self">download file.txt</a>
vidstige
  • 12,492
  • 9
  • 66
  • 110