File downloading from HTML page

M

MP

On my pages I provide links for downloading binary files.
But for some reason, when a link is clicked, browser downloads and opens
the file in text format (i.e. "funny" text appears on the screen).
And if I right-click the link and select the "Save target as...",
extension ".htm" is incorrectly added on the file name. If I provide the
correct extension, then it downloads properly.

What is wrong? Example available here:
http://www.elisanet.fi/matti.puputti/download/files/LaRouteNapoleon_en.htm


Thanks in advance,

MP
http://www.elisanet.fi/matti.puputti/index_en.htm
 
S

Steve Pugh

MP said:
On my pages I provide links for downloading binary files.
But for some reason, when a link is clicked, browser downloads and opens
the file in text format (i.e. "funny" text appears on the screen).
And if I right-click the link and select the "Save target as...",
extension ".htm" is incorrectly added on the file name. If I provide the
correct extension, then it downloads properly.

What is wrong? Example available here:
http://www.elisanet.fi/matti.puputti/download/files/LaRouteNapoleon_en.htm

The files (e.g.
http://www.elisanet.fi/matti.puputti/download/files/LaRouteNapoleon.gdb)
are being served with the HTTP Content-Type header set to text/html.

In other words your server is telling browsers that these are HTML
files. Browsers are thus acting correctly based on what they've been
told.

You need to change the server configuration to serve a more appropriate
HTTP header with these files.

Steve
 
B

Benjamin Niemann

MP said:
On my pages I provide links for downloading binary files.
But for some reason, when a link is clicked, browser downloads and opens
the file in text format (i.e. "funny" text appears on the screen).
And if I right-click the link and select the "Save target as...",
extension ".htm" is incorrectly added on the file name. If I provide the
correct extension, then it downloads properly.

What is wrong? Example available here:
http://www.elisanet.fi/matti.puputti/download/files/LaRouteNapoleon_en.htm

Your server serves these files with a Content-Type of text/html. You seem to
have an Apache server, so creating a .htaccess file (if you do not have one
already) with the content

AddType application/octet-stream .kmz .gdb

in your root directory should fix this problem (add any other extension you
need to the list). There might be more appropriate mime-types than
application/octet-stream for your files - I have not looked it up.
 
A

Andy Dingley

MP said:
On my pages I provide links for downloading binary files.
But for some reason, when a link is clicked, browser downloads and opens
the file in text format (i.e. "funny" text appears on the screen).

Your server is returning a HTTP content-type of text/html This is the
default (for many servers) for anything that isn't specifically
recognised. The browser then treats this as text content and shows it
to you.

As you're running Apache, this is easy to fix. Web search a tutorial on
".htaccess" and it should explain how. You can do this yourself,
without needing to bother the server admins (for almost all sensible
Apache sites). Google also (AFAIR) have some specific notes on the best
way to serve up these KMZ documents.
 
N

niraj.kumar.ait

Make a new apache request . Fill the MIME type of your apache header to
your file format.Then use "send_http_header" .Every thing should work
properly.


Niraj
 
M

MP

Ok, so I already received a bunch or replies (good so!).
As the server is run by my ISP, and I only have access to one of its
folders (where i upload my pages to), I assume I will have to contact my
ISP and ask them to do the actual job.
Just before doing so, could someone tell whether I really could update
the .htaccess file by myself? With my XP?

Thanks again,

MP
 
A

Andy Dingley

MP said:
As the server is run by my ISP, and I only have access to one of its
folders (where i upload my pages to), I assume I will have to contact my
ISP and ask them to do the actual job.

What part of this are you having the problem in understanding?
Nor do servers have "folders". Windows desktops have folders, and they
remove all sharp edges that you don't hurt yourself either. Real
computers have directories. You (or at least your ISP) appears to be
running Apache on Solaris, which counts as real.
 
S

SpaceGirl

Andy said:
What part of this are you having the problem in understanding?

Nor do servers have "folders". Windows desktops have folders, and they
remove all sharp edges that you don't hurt yourself either. Real
computers have directories. You (or at least your ISP) appears to be
running Apache on Solaris, which counts as real.

As do Macs, and some Linux builds. The whole "windowing" environment
removes the sharp edges of computers too. Get back in your command line
box :p In the real world people dont care about these technical things,
and if the "folders" metaphore helps people understand a particular
computing concept better then that's great. Resisting anything that
aids understanding is just dumb. Go read a book and XP (and I dont mean
Windows).
 
M

MP

Building an .htaccess file does not seem like a difficult task, and I
have uploaded one to the "root" of my home site (I know it is not the
"real" root, but I simply call it "root" as it is the main folder where
I have access to, i.e. www.elisanet.fi/matti.puputti/. Rather than being
religious, I try to concentrate on the issue in hand).

But the problem seems to be more on how to tell Apache to take account
of it.
Some tutorials I have read so far (yesterday and before) are telling me
to re-start Apache after updating the file. But I don't know how to do
the re-starting. Somehow it doesn't seem to make sense that a customer
of an ISP would have access to shoot down / restart an application on
the ISP server?

So I seem to be missing the answer on : "How to activate the new
..htaccess settings?".
And if the answer is "Simply upload the file, that's all!", then either
(i) my ISP doesn't allow me to use .htaccess, or (ii) some attributes of
the file are still wrong. Right?


MP
 
S

Steven Saunderson

So I seem to be missing the answer on : "How to activate the new
.htaccess settings?".
And if the answer is "Simply upload the file, that's all!", then either
(i) my ISP doesn't allow me to use .htaccess, or (ii) some attributes of
the file are still wrong. Right?

Can you ask your ISP ? The file (AddType application/octet-stream .kmz
..gdb)is definitely there. There is an Apache setting which tells it to
check or not for .htaccess files. I think it can be specified on a user
by user basis.
 
J

Jukka K. Korpela

Steven Saunderson said:
Can you ask your ISP ?

Given the abbreviated address www.elisanet.fi/matti.puputti/ , I'm afraid the
answer will be (i). This particular service provider (Elisa a.k.a. Kolumbus)
does not let its customers affect server behavior with .htaccess, i.e. the
server has been set to ignore .htaccess. This applies to the normal web space
that private people have as customers. There are more expensive alternatives,
sold basically as business web space. It's price differentiation of a kind.
In other words, they intentionally reduce the functionality, and you have to
pay considerably more to get what many people regard as normal service.

(I once asked them about this. The answer was obscure and mentioned "security
issues", of course.)
The file (AddType application/octet-stream .kmz
.gdb)is definitely there.

Yes, and it is world-readable, as it should be. When the server has been set
to use customer .htaccess files, nothing more needs to be done than to upload
a correct .htaccess file and check the protections (read access to all).
 
M

MP

Jukka said:
Given the abbreviated address www.elisanet.fi/matti.puputti/ , I'm afraid the
answer will be (i). This particular service provider (Elisa a.k.a. Kolumbus)
does not let its customers affect server behavior with .htaccess, i.e. the
server has been set to ignore .htaccess. This applies to the normal web space
that private people have as customers. There are more expensive alternatives,
sold basically as business web space. It's price differentiation of a kind.
In other words, they intentionally reduce the functionality, and you have to
pay considerably more to get what many people regard as normal service.

(I once asked them about this. The answer was obscure and mentioned "security
issues", of course.)


Yes, and it is world-readable, as it should be. When the server has been set
to use customer .htaccess files, nothing more needs to be done than to upload
a correct .htaccess file and check the protections (read access to all).

Thanks! I think this is now both well explained and understood.
I will send an email to Elisa, but same as Yucca seem to think, I am not
too optimistic on getting positive reactions.


I myself work on standardisation of broadcast security solutions, and
have learned at least that security can not be achieved by obscurity
(yes, some of the world's main broadcast security vendors still seem to
build their philosophy on "security by obscurity").
I know Yucca didn't mean this, but couldn't resist on adding the comment
since the words were in his mail...


MP
 
A

Andy Dingley

MP said:
And if the answer is "Simply upload the file, that's all!", then either
(i) my ISP doesn't allow me to use .htaccess,

Then it looks like you have fallen into the (really rather rare)
combination of Apache and clueless admins who've gone to some trouble
to stop you changing this.

Change hosting company. You want to work with people who have a clue
and there's hardly a shortage.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,577
Members
45,054
Latest member
LucyCarper

Latest Threads

Top