PHP quickie - readfile equiv

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi folks.

I'm trying to write a script to read details from a SQL database, insert data 
into a file and download it to the user's browser.  If I use the readfile 
function it works, but if I use get_file_contents and echo the file doesn't 
get downloaded properly.  In both cases, Mozilla opens oowriter, but with 
readfile the document appears correctly, while with get_file_contents/echo it 
show the rich text code.

Anyone any ideas?

Gary

<? // vim: ft=php nowrap ai et 
include_once("gsql1.inc");
include_once("gsecurity.inc");

list($dummy,$o_id,$fname)=explode("/",$_SERVER['PATH_INFO']);
$dets=array_shift(loadhash3("select o_id as key, * from order_details where 
o_id=$o_id"));
if (!$dets['o_id']) {
  echo "Order Details Missing";
  exit;
}
$contents=file_get_contents("/home/httpd/files/$fname");
if ($contents == false) {
  echo "Document Missing";
  exit;
}
header("Content-Type: text/rtf");
header('Content-Disposition: attachment; filename="delivery_note.rtf"');
#readfile("/home/httpd/files/$fname");
echo $contents;

-- 
Gary Stainburn
 
This email does not contain private or confidential material as it
may be snooped on by interested government parties for unknown
and undisclosed purposes - Regulation of Investigatory Powers Act, 2000     

-- 
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [Fedora Magazine]     [Fedora News]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Maintainers]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Legacy]     [Fedora Desktop]     [Fedora Fonts]     [ATA RAID]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [SSH]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Centos]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Tux]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Asterisk PBX]     [Fedora Sparc]     [Fedora Universal Network Connector]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux