Member Avatar

bikertz

I have the code below for a download file link on a web page I designed. It works fine in Firefox, but will not work in Internet Explorer nor Safari. In those instances, the file is displayed as text rather than opening the File Save As dialog box. How can I code this link so that it will Open the File Save As dialog box in all browsers?

<a href="FavoriteRoutes.gpx" download> Garmin GPX file</a>.

Tommy

correct... that is not support on IE or Safari at this time.

To remedy this, you need help server side. If you are using more than just HTML (php, asp.net, jsp, etc..) what you can do is on the response specificy to the browser what you want to happen via the headers you send back..

here is an example on how to handle it via asp.net

Response.Clear();
Response.AddHeader("Content-Length", file.Length.ToString());
Response.AddHeader("Content-Disposition", "inline; filename=" + fileName);
Response.ContentType = fileType;
Response.BinaryWrite(file);
Response.End();
Member Avatar

bikertz

I am using html only, with a little java script thrown in. Can this be done is java script?