i write a php page to upload a image to mysql and a php page to display it
look at this:
============putimg.php===================
<?php if (isset($POST["Submit"]))
{
include "config.inc";
$db = new mydb;
$data = addslashes (fread(fopen($FILES['up_file']['tmp_name'],"rb"),filesize($FILES['up_file']['tmp_name'])));
$a=$POST['description'];
$b=$FILES['up_file']['name'];
$c=$FILES['up_file']['size'];
$d=$_FILES['up_file']['type'];
$sql= "insert into binary_data (description,bin_data,filename,filesize,filetype) values (
'$a','$data','$b','$c','$d')";
$db->query($sql);
echo ($POST['description']);
echo ($FILES['up_file']['name']);
echo ($FILES['up_file']['size']);
echo ($FILES['up_file']['type']);
?>
?>
<?php } else { ?>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body>
<form name="form1" enctype="multipart/form-data" method="post" action=<?php $_SERVER['PHP_SELF']; ?>>
<p>ÎļþÃèÊö£º<br>
<input name=description type=text id=description size="40">
</p>
<p>±£´æÎļþ£º </p>
<p>
<input name=up_file type=file id=up_file size="40">
<input name="MAX_FILE_SIZE" type="hidden" id="MAX_FILE_SIZE" value="1000000">
</p>
<p>
<input type="submit" name="Submit" value="Submit">
</p>
</form>
</body>
</html>
<?php }?>
==============================================
==================getimg.php====================
<?php
include "config.inc";
$db = new mydb;
$a=$_GET['id'];
$db->query("select from binary_data where id=$a ");
if ($db->next_record())
/ header ("Content-type:$db->f(5)"); */
//echo ($db->f(2));
echo ($db->f(2));
?>
==============================================
now it can works ,both upload and display.
but there is something wrong with the image ,looks like that it's data has been changed during it has been upload and download,
who can help me ??
thanks for mail me <jiangpr@lianchuang.com>