By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,968 Members | 1,843 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,968 IT Pros & Developers. It's quick & easy.

download and display links

P: n/a
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).

Jul 17 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
ti***********@nospam.it wrote:
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?

http://cvs.sourceforge.net/viewcvs.p...18&view=markup

Search for download in that page. Also, please refer manual
<http://in2.php.net/header>

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

Jul 17 '05 #2

P: n/a
An anonymous being wrote:
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?
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.

http://www.ietf.org/rfc/rfc2183.txt

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
prescription.

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.
I made <a href="file.txt">Download the file</a>
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?

http://www.w3.org/Provider/Style/NoMechanics
but it display it, and it does not ask me to download it.
Because that's how your browser is configured to handle
resources of that type.
(of course I could download it by clicking the right button,
but my boss doesn't want that: he wants 2 different links).


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

Slainte! & HAGW!

--
Jock
Jul 17 '05 #3

P: n/a
ti***********@nospam.it wrote:
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?


Have a look at the PEAR HTTP_Download package
(http://pear.php.net/manual/en/packag...-download.php). 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
server.

--

Raj Shekhar
System Administrator, programmer and slacker
home : http://rajshekhar.net
blog : http://rajshekhar.net/blog/
work : http://netphotograph.com

Jul 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.