Forum Moderators: coopster
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<?php
include("connection.php");
$id = 1;
$image = mysql_query("SELECT * FROM picture WHERE picid='".$id."'");
$row = mysql_fetch_array($image);
echo $row['pic'];
header("Content-type: image/jpeg");
echo '<img src="'.mysql_result($row, 0).'">';
?>
<FORM ENCTYPE="multipart/form-data" ACTION="" METHOD=POST>
Upload this file: <INPUT NAME="image" TYPE="file">
<INPUT TYPE="submit" VALUE="Send File" name="sub"></FORM>
</body>
</html>
<?php
if (isset($_POST['sub']) ) {
// Temporary file name stored on the server
$tmpName = $_FILES['image']['tmp_name'];
// Read the file
$fp = fopen($tmpName, 'r');
$data = fread($fp, filesize($tmpName));
$data = addslashes($content);
fclose($fp);
// Create the query and insert
// into database.
$query = "INSERT INTO picture (pic) VALUES ('$data')";
$results = mysql_query($query);
// Print results
print "Thank you, your file has been uploaded.";
}
else {
print "No image selected/uploaded";
}
?>