Re: Simple Example of Passing on a file through a PHP script

From: Date: Thu, 04 Jul 2002 02:46:22 +0000
Subject: Re: Simple Example of Passing on a file through a PHP script
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-105347@lists.php.net to get a copy of this message
Thx. I can output the file using readfile(). But the problem is that it appears to output the data in it's raw form. How can I get it to open in the right application? I wasn't going to put the file in the DB. I am just working on a stats program for a couple of sites. One had about 50 downloads and I want info about who is viewing them also. JJ Harrison webmaster@tececo.com www.tececo.com "Richard Lynch" <rich@phpbootcamp.com> wrote in message news:20020703213010.BFZW903.sccrmhc03.attbi.com@[192.168.1.103]... > >I want to show info when my docs are viewed though my stats program. I have > >decieded the best way would be to put the info into a DB through php file > >then output the PDF, Excel, Zip or Powerpoint file. > > > >Only trouble is I have no Idea how to do this > > Stuffing the actual data into your database doesn't really give you much > added value to tracking who is viewing it... > > Write something like this: > > ---------- display.php ---------------------- > <?php > $query = "update stats set count = count + 1 where filename = > '$filename'"; > mysql_query($query) or error_log(mysql_error()); > > # If it's the first time this file has ever been displayed... > if (mysql_affected_rows() < 1){ > $query = "insert into stats(filename, count) values('$filename', 1)"; > mysql_query($query) or error_log(mysql_error()); > } > > readfile($filename); > ?> > --------------------------------------------- > > You can then put your PDF files *outside* your web-tree so nobody can read > them, except like: > > http://yourserver.com/display.php?filename=foo.pdf > > > -- > Like Music? http://l-i-e.com/artists.htm >

« previous php.general (#105347) next »