473,395 Members | 1,937 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

prompting download using header()

hi,

i have been tryin to prompt the download of a file on the server using
the following code:

// send headers, forcing download:
header("Content-type: application/word");
header("Content-Disposition: attachment;
filename=\"files/myfile.doc\"");
....where myfile.doc in folder files is a file on the server relative
to the script:
Warning: Cannot modify header information - headers already sent by
(output started at /home/marty27/public_html/test/oarsome/test_prompt.php:8)
in /home/marty27/public_html/test/oarsome/test_prompt.php on line 10

Warning: Cannot modify header information - headers already sent by
(output started at /home/marty27/public_html/test/oarsome/test_prompt.php:8)
in /home/marty27/public_html/test/oarsome/test_prompt.php on line 11
can anyone tell me what i am doin wrong? i have read the php manual
thingy and to my primitive knowledge, this would work. any help?
cheers

burnsy
Jul 17 '05 #1
1 2666
Am 30 Jul 2004 15:25:31 -0700 schrieb mr_burns:
hi,

i have been tryin to prompt the download of a file on the server using
the following code:

// send headers, forcing download:
header("Content-type: application/word");
header("Content-Disposition: attachment;
filename=\"files/myfile.doc\"");
...where myfile.doc in folder files is a file on the server relative
to the script:
Warning: Cannot modify header information - headers already sent by
(output started at /home/marty27/public_html/test/oarsome/test_prompt.php:8)
in /home/marty27/public_html/test/oarsome/test_prompt.php on line 10


You cannot use header() when the script allready has sent data to the
client.
This "Warning" says, the script (test_prompt.php) has allready done some
output on line 10. So have a closer look there...

And take a closer look at the php manual at
http://de3.php.net/manual/en/function.header.php
somewhere halfway through it says "Remember that header() must be called
before any actual output is sent,..."
Maybe take a look at headers_sent() as well.

hth,
Frank
Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Brian Donovan | last post by:
Hi All, I'm trying to get a forced download to work with IE 6.0. The headers I'm using so far are: header("Cache-Control: private"); header("Content-Type: application/force-download");...
2
by: Matthew Sims | last post by:
Is it possible to force a download without using the readfile function? My website setup consists of my server that serves the web pages plus a high-speed file server elsewhere on the internet...
3
by: kim | last post by:
GOOD morning, I try to open xx.vbs in <href="./xx.vbs"></hef> but it pop up the file download mesage. How can i disabled it? I try another solution like this : set ws =...
0
by: ar | last post by:
Hello, In IE I disable "Automatic prompting for file downloads" which causes the IE information bar to show up when I try to push a file download from an iframe. I want to keep this behaviour. ...
3
by: Bouffa | last post by:
Hello everyone, I suppose you all know force-download scripts. The problem is that these scripts don't allow files to be splitted when downloading them via a download manager. I've found a...
0
by: jinnareddy | last post by:
Hi, I'm unable to download a file that is having a 2-byte char in its name (e.g.テ) using force download option. Though, am able to download file names involving ASCII chars. I have tried URL...
1
by: Adrian | last post by:
Using: Mysql 5.0.15 php 5.1.6 apache 2.2.3 I am trying to create a download link for various pdfs which I have stored in a mysql DB. I am having trouble with the header fields when clicking...
6
by: empiresolutions | last post by:
Using the following code, files greater than 10Megs do not download. Less than 10 is working. Can anyone explain why? Files that will be downloaded are 5G plus in size. function download() {...
1
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Many websites have a form or a link you can use to download a file. You click a form button or click...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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
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
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
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,...

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.