<?php
error_reporting(E_ALL ^ E_DEPRECATED);
// connection to database
include 'database.php';
?> <?php
if (isset($_FILES['image']) && $_FILES['image']['size'] > 0) {
//// 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($data);
fclose($fp);
}
$name=$_POST['name'];
$email=$_POST['email'];
$result = mysql_query("INSERT INTO mytable (name,email,imageData)VALUES ('$name','$email','$data')", $link);
if(!$result)
{
die("Database query failed: ". mysql_error());
}
// Print results
if($result==1){
print "Thank you, your file has been uploaded.";
}
else
{
print "No image selected/uploaded";
}
?>
//i'm trying to save user details with his photo int
mysql database with blob data type. The name and email
insert into the table but the image does not.
Please help. Thanks in advance
kingwash 0 Newbie Poster
cereal 1,524 Nearly a Senior Poster Featured Poster
AndrisP 193 Posting Pro in Training
diafol commented: This needs to be a sticky! Heh heh. +14
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.