Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Warning: Cannot modify header information 1

Status
Not open for further replies.

zyrag

IS-IT--Management
Dec 4, 2002
252
PH
i tried to create a download script (download.php). The content of the script goes like:

<?php
$path=&quot;./myfiles&quot;;
$filename=&quot;computer.jpg&quot;

header(&quot;Content-Disposition: attachment; filename=$filename&quot;)
header(&quot;Content-Transfer-Encoding: binary&quot;);
header(&quot;Content-Type: applicatin/octet-stream&quot;);
readfile(&quot;$path/$filename&quot;);
?>

the output:

Warning: Cannot modify header information - headers already sent by (output started at /usr/local/apache2/htdocs/mypage/download.php:2) in /usr/local/apache2/htdocs/mypage/download.php

These messages points at all the lines beginning the &quot;header&quot;.

What does this error means? How do i go about it?

thanks,
 
[tt]<?php
$path=&quot;./myfiles&quot;;
$filename=&quot;computer.jpg&quot;;

header(&quot;Content-Disposition: attachment; filename=$filename&quot;);
header(&quot;Content-Transfer-Encoding: binary&quot;);
header(&quot;Content-Type: applicatin/octet-stream&quot;);
readfile(&quot;$path/$filename&quot;);
?>[/tt]
Note the missing semicolons. //Daniel
 
oops, sorry... the actual script do have all these semicolons and i dont say any other typo errors.

what else could be the reason for these errors? i'll be looking at some configuration files for both php and apache. meanwhile, hope you could share your ideas.

thanks,
 
make sure that no output is sent to the browser before u use header.
is there any blank line or blank space before ur php start tag?

spookie --------------------------------------------------------------------------
I never set a goal because u never know whats going to happen tommorow.
 
daniel, i removed the html tags e.g.,<html>,etc. and with my script starting with <?php tag. the error messages were gone, but it displays the content of the file, i.e, the computer image in the browser. i want it to be copied into my local win98 PC instead. how? any further corrections?

ne4x4, my php4.3.0 is installed together with my apache2.0.40 at my redhat 7.3 server in my LAN.

thanks again,
 
thanks everybody, i got it working now.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top