note 42457 added to function.header
| From: | toni at rn2 dot php dot net | Date: | Mon, 17 May 2004 15:52:06 +0000 |
| Subject: | note 42457 added to function.header | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-69722@lists.php.net to get a copy of this message | ||
IN PHP
i need to use the function readfile(filename) to show in a box the file to download
i get the filename from a SELECT in sql from one table of the DATABASE, but the function reads from
the local directory of the server(c:\myproject\filename.pdf)
i don t know how to get the file.
in the table at the database i have of each file , the datasize, filename, remoteip , i think that
the solution could be with this but i don t know how.
i think the solution is access to the direction of the database that is stored the file but i don t
know how to implement, (http:ipadress/filename) or with another way ftp:/....
because when i put only the name of the file INSIDE the readfile command, appear the box of the
dowload but with the path of the my local scripts directory
THIS IS THE CODE I USE
function Download($rFilename,$rdatasize)
{
$TheFile = basename($rFilename);
header( "Content-Type: application/octet-stream");
// header( "Content-Length: ".filesize($rFilename));
header( "Content-Length: ".$rdatasize);
header( "Content-Disposition: attachment; filename=".$TheFile."");
readfile($rFilename);
}
$conexion = odbc_connect("DSNinfi","","")
or die("Error: No possible connection");
$sSQL = "SELECT filename,datasize FROM VERSION WHERE document_id = $_REQUEST[file]";
$document = odbc_exec($conexion,$sSQL)
or die("Error: No possible make sql");
Download(odbc_result($document, "filename"),odbc_result($document, "datasize"));
THANKS
----
Manual Page -- http://www.php.net/manual/en/function.header.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+42457
Delete -- http://master.php.net/manage/user-notes.php?action=delete+42457&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+42457&report=yes
Search -- http://master.php.net/manage/user-notes.php