0

hi.
can anyone help me.
i want to download file from local folder using the paths store in database.
please..

2
Contributors
2
Replies
3
Views
9 Years
Discussion Span
Last Post by ika
0
<a href="<? echo $userfile;?>" target="_blank"><img src="/images/word_icon.gif" width="30" height="30" border="0" align="right"></a>
0
<?php
include('conn.php');

if(isset($_GET['id'])) 
{

$id    = $_GET['id'];
$name    = $_GET['name'];
$query = "SELECT name, type, size, path " .
         "FROM upload WHERE id = '$id'";

$result = mysql_query($query) or die('Error, query failed');
list($name, $type, $size, $path) = mysql_fetch_array($result);


$content = file_get_contents("C:/AppServ/www/Penerbit/files/".$_GET['name']);


($content !== false) {
header("Content-length: $size");
header("Content-type: $type");
header("Content-Disposition: attachment; filename=$name");
echo $content;
exit;
} 
else {
echo "<SCRIPT> alert('Error reading file $content content ');</SCRIPT>";
exit;
}
}
?>

i use those code..but it cause error like..file_get_contents function and failed to open stream

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.