Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Header() script works here, not there...
Old 09-19-2008, 01:58 PM Header() script works here, not there...
Junior Talker

Posts: 3
Name: George Brooks
Location: Truckee, CA
Trades: 0
The following script works properly in my test environment (Apache 2.2.8, php 5.2.5), but not on my live host's environment (Apache 2.2.6, php 5.2.5):

<?php
$filename = $_SERVER['DOCUMENT_ROOT'] . "/waiver.pdf";
header("Cache-Control: Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Description: File Transfer");
header('Content-disposition: attachment; filename='.basename($filename));
header("Content-Type: application/pdf");
header("Content-Transfer-Encoding: binary");
header('Content-Length: '. filesize($filename));
readfile($filename);
?>

In the test environment I get an opportunity to save or open the file. At the live environment, the browser remains at the link that triggers the above code. Behavior is the same in both IE7 & Firefox2.

I imagine there's a server setting somewhere that makes the difference. Any clues on where best to look?

TIA.

George
geoB is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 09-19-2008, 07:41 PM Re: Header() script works here, not there...
rogem002's Avatar
PHP Chap

Posts: 843
Name: Mike
Location: United Kingdom
Trades: 0
Change the code to:

PHP Code:
<?php
$filename 
$_SERVER['DOCUMENT_ROOT'] . "\waiver.pdf";
header("Cache-Control: Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Description: File Transfer");
header('Content-disposition: attachment; filename='.basename($filename));
header("Content-Type: application/pdf");
header("Content-Transfer-Encoding: binary");
header('Content-Length: 'filesize($filename));
readfile($filename);
?>
__________________
My Blog/Site:
Please login or register to view this content. Registration is FREE
rogem002 is offline
Reply With Quote
View Public Profile Visit rogem002's homepage!
 
Old 09-19-2008, 07:57 PM Re: Header() script works here, not there...
Junior Talker

Posts: 3
Name: George Brooks
Location: Truckee, CA
Trades: 0
Um...okay. How does this differ from the original? 'Cuz the behavior certainly isn't any different.

G
geoB is offline
Reply With Quote
View Public Profile
 
Old 09-20-2008, 10:01 AM Re: Header() script works here, not there...
Junior Talker

Posts: 3
Name: George Brooks
Location: Truckee, CA
Trades: 0
There is now a large dent in my forehead from the big dope slap I gave myself. In uploading a file to display what was being used as document root I discovered that I had not uploaded the file containing the call to the header script function. DUH! Not a server issue - it's a programmer issue!

G
geoB is offline
Reply With Quote
View Public Profile
 
Old 09-20-2008, 04:00 PM Re: Header() script works here, not there...
rogem002's Avatar
PHP Chap

Posts: 843
Name: Mike
Location: United Kingdom
Trades: 0
I believe that is a eye-Dee-ten-tee error (Joke). I change the line:
PHP Code:
$filename $_SERVER['DOCUMENT_ROOT'] . "/waiver.pdf"
to
PHP Code:
$filename $_SERVER['DOCUMENT_ROOT'] . "\waiver.pdf"
Because sometimes i program on a windows and forget the different folder structure.
__________________
My Blog/Site:
Please login or register to view this content. Registration is FREE
rogem002 is offline
Reply With Quote
View Public Profile Visit rogem002's homepage!
 
Old 09-21-2008, 10:32 AM Re: Header() script works here, not there...
Ultra Talker

Posts: 483
Trades: 0
Quote:
Originally Posted by rogem002 View Post
Because sometimes i program on a windows and forget the different folder structure.
That shouldn't matter at all... PHP in Windows accepts, understands and supports forward slashes for directory separators. That's why I always use them... plus, you get the added benefit of not being stung when you have a subdirectory that starts the the letter 't', for example, and you don't escape the backslash.
__________________

Please login or register to view this content. Registration is FREE
TwistMyArm is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Header() script works here, not there...
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.17574 seconds with 12 queries