Safari not cooperating

I am exporting fields in a database to a .csv file on an enterprise server, then creating a link to download the file in a browser. When you click the link, the .csv file will download using Chrome but Safari will only display it.

The code for the link is:
LLink={<a href="http://IP Number/}+LLinkName+{.csv" download="ListName">download now</a>}

LLink is a variable that contains the name of the file on the server.

Any ideas to get Safari to download it? Thanks.

It’s impossible to tell if you’re handling spaces and curly brackets correctly but you should build the link to include the download attribute.

<a download="LLinkName.csv"  href="http://IP%20Number/%7D+LLinkName+%7B.csv">download now</a>

or 

<a download  href="http://IP%20Number/%7D+LLinkName+%7B.csv">download now</a>
1 Like

Cool! That’s something I didn’t know about.

Thanks James. For some reason my code didn’t come through correctly as I didn’t realize that it converted my link code to a link instead of displaying the code.

I am using the download attribute. There are no spaces in the file name. I don’t think your code would work without bracketing. At least it didn’t for me until I bracketed it. As I said, it works perfectly in Chrome, just not Safari. I’ll try tp post the code again assuming I would have <a and the closing a on both ends inside the brackets:

LLink= {href=“http://IP#/}+LLinkName+{.csv” download=“DList”>download now}
cgiHTML= LLink

Jim R: I just looked up the download attribute on w3 schools website. They are a great resource.

Obviously I don’t know how to display code properly on this forum. When I put the a tag in the code, it produced the result instead of displaying the code. How did you write your code? Thanks.

The easiest way to protect the code as written is to use the Preformatted text tool in the editor. Highlight the code text you enter or paste and then click the tool.

image

I did this to your original code above.

Thanks Gary.

<a download href="http://IP%20Number/%7D+LLinkName+%7B.csv">download now</a>

Jim,

If I use your code above in a procedure like this(the ip number is illustrative):
LLink=<a download href="http://192.168.1.1/%7D+LLinkName+%7B.csv">download now</a>

Panorama responds with “Operand expected but not found”. If I enclose the code in any way (eg:pipes), Panorama likes the procedure but both browsers through the error “The requested URL /}+LLinkName+{.csv was not found on this server.”.

Thanks to Gary, you can see the code that works in my original post now, however, it only works in Chrome.

I would try:

LLink={<a download href="http://192.168.1.1/%7D}+LLinkName+{%7B.csv">download now</a>}

The link text should be quoted with the LLinkName variable added in the middle.

Thanks Gary, but it throughs the same message, “The requested URL /}DetaineeList32720{.csv was not found on this server.”

Again, my original code downloads the file in Chrome. It is bracketed. as follows:

LLink={<a href="http://192.168.1.1.119/}+LLinkName+{.csv" download="DList">download now</a>}

I think %7d is a curly bracket so a bracket is being bracketed. Make sense?

I think you may be right. The %7d and %7B should probably be removed from the string so that you would have:

LLink={<a download href="http://192.168.1.1/}+LLinkName+{.csv">download now</a>}

My best guess from what I can see. Maybe James can set us straight.

W3school site states the ‘download’ attribute is not supported by Safari, although all the other browsers they list support it.

Thanks John but where did you see that? According to this page on W3 schools, it is supported.

Ok, I found another page on W3 schools that says it isn’t supported. I can’t tell which one was the latest post but I know it doesn’t work with Safari.

At this point, I’m just going to ask my client to use Chrome for this task.

It should always be possible to use a right-click to download the linked file.

CanIUse is a very popular site for determining what features work with what browser. This search leads me to believe that the download feature is supposed to work in Safari since version 10.1 in March 2017.

That page led me to an official webkit support page that also indicates that it is supposed to work.

https://webkit.org/status/#feature-download-attribute

Are your users running a 4 year old version of Safari, by any chance? (It looks like in Chrome this was supported since 2011.)

No they are using a newer version and I’m using Safari 11.2. I’ve also tried it with High Sierra.

W3 schools also says it should work with Safari 10.1 or greater.

KJM:

You’re right. Safari kept displaying the file and I was trying to download that. If I right-click the LINK, I can download the file. Thanks Kurt.