Standalone-offline-local html download file
up vote
0
down vote
favorite
I'm implementing a feature in my web-app that let users download a ZIP file.
the ZIP file has this structure:
- my-files.zip
- index.html
- attachments
- file1.png
- file2.txt
- ...
- fileN.ext
the index.html
is just a list of the attachments:
<!DOCTYPE html>
<html>
<head>
...
</head>
<body>
<ul>
<li><a href="attachments/file1.png" download="birthday.png">birthday.png</a></li>
<li><a href="attachments/file2.txt" download="notes.txt">notes.txt</a></li>
...
</ul>
</body>
</html>
Suppose the user unzips the archive and opens index.html
with a browser.
I'm interested in:
- clicking on a link should prompt the download (Save as...) dialog
- the download filename should be different from local filename
Currently:
- Firefox 62/63: it is behaving correctly
- Edge 17: it is behaving correctly (incredible)
- Chrome 70: clicking on a link makes the browser navigate to the content - it is ignoring the
download
attribute - IE 11: same as Chrome
Is there a general approach that works with most browsers (even using JS) to achieve this behavior?
Alternatively, is there a specific Chrome quirk/hack?
Thanks
html5 file download local
add a comment |
up vote
0
down vote
favorite
I'm implementing a feature in my web-app that let users download a ZIP file.
the ZIP file has this structure:
- my-files.zip
- index.html
- attachments
- file1.png
- file2.txt
- ...
- fileN.ext
the index.html
is just a list of the attachments:
<!DOCTYPE html>
<html>
<head>
...
</head>
<body>
<ul>
<li><a href="attachments/file1.png" download="birthday.png">birthday.png</a></li>
<li><a href="attachments/file2.txt" download="notes.txt">notes.txt</a></li>
...
</ul>
</body>
</html>
Suppose the user unzips the archive and opens index.html
with a browser.
I'm interested in:
- clicking on a link should prompt the download (Save as...) dialog
- the download filename should be different from local filename
Currently:
- Firefox 62/63: it is behaving correctly
- Edge 17: it is behaving correctly (incredible)
- Chrome 70: clicking on a link makes the browser navigate to the content - it is ignoring the
download
attribute - IE 11: same as Chrome
Is there a general approach that works with most browsers (even using JS) to achieve this behavior?
Alternatively, is there a specific Chrome quirk/hack?
Thanks
html5 file download local
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I'm implementing a feature in my web-app that let users download a ZIP file.
the ZIP file has this structure:
- my-files.zip
- index.html
- attachments
- file1.png
- file2.txt
- ...
- fileN.ext
the index.html
is just a list of the attachments:
<!DOCTYPE html>
<html>
<head>
...
</head>
<body>
<ul>
<li><a href="attachments/file1.png" download="birthday.png">birthday.png</a></li>
<li><a href="attachments/file2.txt" download="notes.txt">notes.txt</a></li>
...
</ul>
</body>
</html>
Suppose the user unzips the archive and opens index.html
with a browser.
I'm interested in:
- clicking on a link should prompt the download (Save as...) dialog
- the download filename should be different from local filename
Currently:
- Firefox 62/63: it is behaving correctly
- Edge 17: it is behaving correctly (incredible)
- Chrome 70: clicking on a link makes the browser navigate to the content - it is ignoring the
download
attribute - IE 11: same as Chrome
Is there a general approach that works with most browsers (even using JS) to achieve this behavior?
Alternatively, is there a specific Chrome quirk/hack?
Thanks
html5 file download local
I'm implementing a feature in my web-app that let users download a ZIP file.
the ZIP file has this structure:
- my-files.zip
- index.html
- attachments
- file1.png
- file2.txt
- ...
- fileN.ext
the index.html
is just a list of the attachments:
<!DOCTYPE html>
<html>
<head>
...
</head>
<body>
<ul>
<li><a href="attachments/file1.png" download="birthday.png">birthday.png</a></li>
<li><a href="attachments/file2.txt" download="notes.txt">notes.txt</a></li>
...
</ul>
</body>
</html>
Suppose the user unzips the archive and opens index.html
with a browser.
I'm interested in:
- clicking on a link should prompt the download (Save as...) dialog
- the download filename should be different from local filename
Currently:
- Firefox 62/63: it is behaving correctly
- Edge 17: it is behaving correctly (incredible)
- Chrome 70: clicking on a link makes the browser navigate to the content - it is ignoring the
download
attribute - IE 11: same as Chrome
Is there a general approach that works with most browsers (even using JS) to achieve this behavior?
Alternatively, is there a specific Chrome quirk/hack?
Thanks
html5 file download local
html5 file download local
edited Nov 22 at 9:36
asked Nov 22 at 9:25
Michele Mariotti
5,72543163
5,72543163
add a comment |
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53427617%2fstandalone-offline-local-html-download-file%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown