<form action="index.php" method="POST" enctype="multipart/form-data">
File :
<input type="file" name="image" />
<input type="submit" value="Upload" />
</form>
<?php
include_once('db.php');
$file = $_FILES['image']['tmp_name'];
if(!isset($file))
echo"Please select an Image.";
else
{
$image = addslashes(file_get_contents($_FILES['image']['tmp_name']));
$image_name = addslashes($_FILES['image']['tmp_name']);
$image_size = getimagesize($_FILES['image']['tmp_name']);
if ($image_size==FALSE)
echo "that's not an image.";
else
{
if(!$insert = mysql_query("INSERT INTO image VALUES('','$image_name','$image') "))
echo"Problem on uploading image.";
else
{
$lastid = mysql_insert_id();
echo "Image Uploaded.<p />Your image:<p /><img src=get.php?id=$lastid>";
}
}
}
?>
Table name : image
fields : id, name, image
Thursday, May 23, 2013
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment