Thank you friend.
but i couldn't understand what you said.
this is my table structure
username varchar(30) PRIMARY KEY
name varchar(30)
type varchar(30)
size int(11)
content mediumblob
This is my requirement.
Admin will upload each client's agreement through website. which will be stored in the mysql database.
clients will login into the website and they can view a link "Download your agreement"
when client click the link it will call the "download.php" file. which should download the PDF file of the particular client from the database.
i was able to upload the file. but when i try to download the file through client login, its downloading the "download.php" (blank - no code inside) file.
why i'm getting this problem ???
<<download.php>>
<?php
$dbserver = "policedsn";
$uname = "exppo";
$pas = "exp";
$db = "polic";
mysql_connect("$dbserver","$uname","$pas") or die("Could not connect");
mysql_select_db("$db");
$id = "my"; // PDF file of username="my" should be downloaded now
$query = "SELECT name, type, size, content " .
"FROM upload WHERE username = '$id'";
$result = mysql_query($query) or die('Error, query failed');
list($name, $type, $size, $content) = mysql_fetch_array($result);
header("Content-length: $size");
header("Content-type: $type");
header("Content-Disposition: attachment; filename=$name");
echo $content;
exit;
?>
<<upload.php>>
$username=$_POST['client_username'];
$username = strtolower($username);
if($_FILES['userfile']['size'] > 0)
{
$fileName = $_FILES['userfile']['name'];
$tmpName = $_FILES['userfile']['tmp_name'];
$fileSize = $_FILES['userfile']['size'];
$fileType = $_FILES['userfile']['type'];
$fp = fopen($tmpName, 'r');
$content = fread($fp, filesize($tmpName));
$content = addslashes($content);
fclose($fp);
if(!get_magic_quotes_gpc())
{
$fileName = addslashes($fileName);
}
$conn=odbc_connect('server-name','username','password');
$query = "INSERT INTO upload (username,name, size, type, content ) ".
"VALUES ('$username', '$fileName', '$fileSize', '$fileType', '$content')";
$result = odbc_do($conn, $query);
odbc_close($conn);
Please Anybody help me out !!!!! :-(