As i am working out on uploading image in the upload folder of my system's directory and parallely saving the uploaded image name in the mysql database server. The code is working but the image name is not saving the database. Instead of saving the image name it saves the name as BLOB-8B, BLOB-10B etc..Can anyone tell me wats my mistake.
And also creating database the which datatype should i use for saving the image in database. Please suggest...
My code:
uploadimage.php
Code: Select all
<?php
if ($_POST["action"] == "Load")
{
$folder = "upload/";
move_uploaded_file($_FILES["filep"]["tmp_name"] , "$folder".$_FILES["filep"]["name"]);
echo "<p align=center>File ".$_FILES["filep"]["name"]."loaded...";
$result = mysql_connect("localhost", "root", "") or die ("Could not save image name Error: " . mysql_error());
mysql_select_db("tests") or die("Could not select database");
mysql_query("INSERT into dbProfiles (photo) VALUES('".$_FILES['filep']['name']."')");
if($result)
{
echo "Image name saved into database";
}
}
?>Code: Select all
<html>
<head>
</head>
<body>
<form action="uploadimage.php" method="post" enctype="multipart/form-data">
<table border="0" cellspacing="0" align="center" cellpadding="3" bordercolor="#cccccc">
<tr>
<td>File:</td>
<td><input type="file" name="filep" size=45></td>
</tr>
<tr>
<td colspan=2><p align="center">
<input type="submit" name="action" value="Load">
</td>
</tr>
</table>
</form>
<?php
?>
</body>
</html>