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

Recommended Answers

All 2 Replies

<a href="<? echo $userfile;?>" target="_blank"><img src="/images/word_icon.gif" width="30" height="30" border="0" align="right"></a>
<?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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.