How to create a download link when opening a file from local file system - html

We are shipping some docu stuff on a cd and to have a better overview over all the files, we want to provide an index of all files as html, that can be put on the cd. The idea is that the user can download the wanted files just like from any webpage.
The problem is, that I can open the pdf in the browser but i want the download dialog to pop up if i click the button so I added the download="some-name.pdf".
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Demo</title>
<base href=".">
</head>
<body>
Download file
</body>
</html>
Using this via webserver (http) seems to work, but I cannot get it to work from the local file system...
To reproduce, just store the snipped in a file, create a folder "files" next to it and put any pdf file with an .html extension and name it test.pdf. Then open the page in a browser like Chrome or FireFox. (I am on a mac, but i guess it is the same for Windows or Linux?!)
Any help would be appreciated.

Related

Internet explorer and edge attempt to download a file as html

I have an apache server that serves an html page with content similar to the following:
<html>
<head>
<link href="meta/style.css" rel="stylesheet" type="text/css" charset="UTF-8">
</head>
<body>
<h1>Welcome</h1>
<p><b><li>Welcome to download page</b></li>
</p>
<p>
file1.7z<br><br>
file2.7z
</p>
</body>
</html>
When I click on the file1.7z or file2.7z link, chrome starts downloading it a 7z file, but internet explorer and edge attempt to download it as html file. If I select all files in the save as dialog box and change extention to 7z, the downloaded file is a valid 7z file.
I have found out about the download attribute which will probably fix this for Edge, but it looks like Internet explorer and other browsers may not even support this.
Is there any apache server configuration I can set, or anything I can add to my html page's header, to force all browsers to download this as a 7z file?
#user13267 It sounds like you may need to add the MIME type: application/x-7z-compressed
I think you would need to do so on your server at this path:
/etc/apache2/mods-enabled/mime.conf

When opened with google chrome, html code is shown as text [duplicate]

This question already has answers here:
when opening an html file on browser, I see the source code
(2 answers)
Closed 2 years ago.
The below html code was in a notepad text editor. Saved and then opened the file using google chrome. However it showed the same code only.
<!DOCTYPE html>
<html>
<head>
<title> HTML Cheat sheet</title>
</head>
<body>
</body>
</html>
Edit:
I did save as .html
However when i opened the using chrome it comes as url....html.txt
I think the .html i saved as was used as filename.html.txt where txt is the only extension. Any idea how to resolve it?
Please save the file with .html extension like index.html then open it chrome
I think you do not save file in .html format
I think the problem is, you have saved your file like index.html.txt format so this is main problem, please rename it like index.html.txt to index.html (remove .txt). This is html extension .html format and also i think in your computer hide extension so you do not see this extension so show it and rename it.
<!DOCTYPE html>
<html>
<head>
<title> HTML Cheat sheet</title>
</head>
<body>
This is body
</body>
</html>
You have to save the file as a .html
Open text editor copy the code and from Files dropdown on the top left corner click Save As and save your file as a WebPage.html
REMEMBER: While always saving a program file of any programming language save it with it's respective extension: Like (.html) for HTML files and (.py) for python files. If you forget to save then your system opens the file with the default notepad.
Now go to (Save as...) and edit the extension from .txt or other extension to .html

How can I see how HTML that I write will look on the web?

I'm embarrassed to have to ask this, but I'm really new to HTML and web development.
All I want is a simple way to display the results of HTML that I write. That is, to see how my HTML will look on the web.
I can't seem to open an HTML file in my default browser: Chrome. I downloaded Microsoft Expression and can type in HTML code but can't find a way to display its results.
I'm not going to write much HTML so I'm looking for a quick, simple approach.
Go to https://jsfiddle.net/ to play around with html. It will provide you with warnings if your html is malformed.
Here's an answer to a question that you didn't ask, but is probably what you are looking for:
Create a new file, call it index.html and make sure that the extension is indeed .html. The extension could be something you don't want if you don't have this checkbox checked on windows.
Right click your file and open it in notepad, then paste this inside it:
<html lang="en">
<head>
<title>Simple Page</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
</head>
<body>
<h1>It works!</h1>
<ul>
<li>Lists work too</li>
<li>Lists work three</li>
</ul>
</body>
</html>
Save the file (Ctrl + S or File > Save)
Open your browser (chrome or firefox), and drag the file over your tab bar, or right click the file, choose open with... and pick your browser.
You should now see the result of the HTML file.
In short, you should be able to open the HTML file in your browser. However, you may see nothing (blank) if your HTML is not correctly formatted.
Save your file with ‘.html’ extension. For example ‘index.html’. And then you can right on the file and select ‘open with’ and choose the browser that you want. Or else you can open your browser first. Then go to File menu -> Open -> Select index.html

HTML Download file

I have tried to make a link that makes you download a file when you click it, but when i try it, it
only opens the link and starts the file in the browser. Im using internet Explorer by the way.
Code:
<html>
<head>
<title>Test Website</title>
</head>
<body>
<h1>My Games:<br></h1>
My Epic Game
</body>
</html>
(Don't mind the "AdventureGame.swf.swf, i accidently named it like that). Why doesn't the file download?
Nvm, i uploaded zip folders with the files inside and now it is downloading correctly.
Try adding a download at the end of the opening tag:
<a href="http://erikwallstrom.16mb.com/AdventureGame.swf.swf" download>My Epic Game</a>
http://jsfiddle.net/wfmhh2o2/
You could use the HTML5 download attribute like so:
<a href="path/to/file" download>Click here to download</a>
This opens a "save as" dialog regardless of file type without taking you away from the page.
Force a browser to save file as after clicking link
[EDIT]
Try this : How to start automatic download of a file in Internet Explorer?.
If you have the last version of IE it should work

Direct downloading link in browser opening file instead of downloading it

I am trying to create a html simple website on IIS that will help downloading files.
<!doctype html>
<html lang="en">
<head>
</head>
<body>
Start automatic download!
</body>
</html>
This is running file. On clicking "Start automatic download!" it is downloading newUpdater.xml in browser. But, If I directly give this download link in browser (below), it is opening the XML file in all browsers(chrome, firefox).
http://169.254.68.202/newUpdater.xml
Any Idea How to fix this. I think this is possible as
http://dl.google.com//googletalk//googletalk-setup.exe
this link on browser will start downloading gtlk directly.