download and display links

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I have a txt file in my server.
I have to provide to the user 2 links.
One link is to download the file and the other one is to display it inside
the browser.
Is it possible?
I made <a href="file.txt">Download the file</a> but it display it, and it
does not
ask me to download it.
(of course I could download it by clicking the right button,
but my boss doesn't want that: he wants 2 different links).

Re: download and display links wrote:
Quoted text here. Click to load it

Search for download in that page. Also, please refer manual

<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com    Blog: /

Re: download and display links

An anonymous being wrote:

Quoted text here. Click to load it

As Michael said, not reliably.  The WWW doesn't work that
way.  You the publisher hold little sway over how a user
handles your resource.

The ratified way of suggesting presentational information is
through the Content-Dispostion header.  The disposition type
'attachment' indicates that the presentation of the resource
should not be automatic.  That's a 'should not', not 'must
not'; so even software that honours RFC2183 may, under
certain circumstances, present the resource automatically.  

Besides, note carefully the wording of RFC2183:

| Bodyparts can be designated `attachment' to indicate that
| they are separate from the main body of the mail message,
| and that their display should not be automatic, but
| contingent upon some further action of the user.

Nothing there requires that the resource be saved to disk.

Content-Disposition, though mentioned in sec. 19.5.1, is not
a part of HTTP1.1, so there's no obligation for browsers to
support it.  To me, it's a step in the wrong direction for
the web, and I'd dismiss it straight off.  Description not

The other, more common mistake is to claim that the resource
is something that it isn't by sending a misleading Content-
Type header.  Resources are often sent as application/octet-
stream, which means 'arbitrary binary data'.  If there's a
more appropriate type, it should be used instead.  A plain
text resource, for example, should be labelled text/plain.

Quoted text here. Click to load it

That should set alarm bells ringing: verbs are out of place
in link text.  A link itself doesn't do anything; it is
simply a relationship or connection, as the HTML spec puts
it.  With that in mind, how would you set apart your
download link now?

Quoted text here. Click to load it

Because that's how your browser is configured to handle
resources of that type.

Quoted text here. Click to load it

I want a cool breeze and bright sunshine tomorrow, but
Mother Nature brooks no defiance.

Slainte! & HAGW!


Re: download and display links wrote:
Quoted text here. Click to load it

Have a look at the PEAR HTTP_Download package
( ).  It
might make your task easier.  However as others have pointed out,  how
your content is handled depends on the client's browser not your


Raj Shekhar
System Administrator, programmer and  slacker
home :
blog : /
work :

Site Timeline