CREATE TABLE image(id int auto_increment primary key, type varchar(25), size int, data blob);
<form name=”frmAddImage” action=”/image/add.php” method=”post” enctype=”multipart/form-data”>
<input type=”file” name=”image” />
<input type=”submit” value=”Add” />
</form>
<?php
// validate…
$tmpName = $_FILES[‘image’][‘tmp_name’];
$type = $_FILES[‘image’][‘type’];
$size = $_FILES[‘image’][‘size’];
$fp = fopen($tmpName, ‘r’);
$data = fread($fp, filesize($tmpName));
$data = addslashes($data);
fclose($fp);
$sql = “INSERT INTO image SET type=’$type’, size=$size, data=’$data'”;