473,507 Members | 2,374 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

download and display links

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
3 1845
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1395
by: Miguel Dias Moura | last post by:
Hello, in my web site i display some links to PDF files. This links are loaded from a database. Anyway, when i click these links the PDF files are open in the visitors browser and in Acrobat. ...
3
18789
by: David Reynolds | last post by:
Does anyone know how I could stream Excel to the browser for download without saving the file somewhere first. I wasn't sure how I would go about it.
2
1075
by: Rani | last post by:
Hi guys i would like to add a file download capebility to my website how do i do that ? currently i have few pages on my web site and would like add a regulation file for the users to download....
5
12270
by: Neil Rossi | last post by:
I have an issue with a particular ASP page on two web servers. Let's call these servers Dev1 and Beta1. Both Servers are running IIS 5, Windows 2000 SP4 with "almost" all of the latest patches. ...
16
3222
by: matt | last post by:
I have used some free code for listing files for download, but I want to send an email to the administrator when the file has been downloaded. I have got some code in here that does it, but it will...
4
3259
ak1dnar
by: ak1dnar | last post by:
Hi, How to display a file download dialog box using PHP. is there any header for this. Currently i have uploaded some .pdf and .doc files to the web site. Now i need to give the download links to...
7
2609
by: lawrence k | last post by:
I've got a music studio for a client. Their whole studio is run with Macintosh computers. Macintosh computers allow file names to have open white spaces, such as "animal hospital.mp3". I have a...
1
2070
by: naza | last post by:
Before I start I would just like to say that I am totally new to programming so the things that I am going ask probally will sound basic and I might sound I bit ambitious in what I want to do. The...
12
3997
by: Bob Bedford | last post by:
I've to build a website where the customer can buy an image. I'm thinking in the 2 ways to let people get those images: receive them by Email or send them an image link wich validity is limited in...
0
7223
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7319
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7376
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7031
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7485
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5623
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3191
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1542
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
760
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.