file download fixed
| From: | Data Driven Design | Date: | Sat, 04 Aug 2001 17:54:55 +0000 |
| Subject: | file download fixed | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-61258@lists.php.net to get a copy of this message | ||
Rasmus thatnks for your help, this code works.
<?php
mysql_connect("localhost","user","pass");
mysql_select_db("db");
$query = "SELECT file_path from photos where photos_id=$photos_id";
$result = mysql_query($query) or die(mysql_error());
$row = mysql_fetch_row($result);
$path = $row[0];
$file_name = basename($path);
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=\"$file_name\"");
header("Content-Transfer-Encoding: binary");
readfile($path);
?>
Data Driven Design
1506 Tuscaloosa Ave
Holly Hil, FL 32117
http://www.datadrivendesign.com
http://www.rossidesigns.net