i want to upload the employee profile picture into mysql database using php. i tried this coding. image uploaded successful but when i fetch that image on browser it shows me text character like this (ÿØÿàJFIFHHÿáLExifMM*bj(1r).
one more problem is below 20kb size images only uploaded into mysql. how to upload large img files into mysql with specific width and height? how to fetch that image?
html page code :
<form enctype="multipart/form-data" action="uploadimg.php" method="post" name="upimg">
<input name="MAX_FILE_SIZE" value="102400" type="hidden">
<input name="image" accept="image/jpeg" type="file">
<input value="Submit" type="submit">
<?php
include("dbconfig.php");
$sql = mysql_query ( "SELECT * FROM reguser" ) or die(mysql_error());
while($row = mysql_fetch_array($sql))
{
echo "<td>" . $row['emp_img'] . "</td>";
}
?>
uploadimg.php code :
<?
include("dbconfig.php");
if (isset($_FILES['image']) && $_FILES['image']['size'] > 0) {
$tmpName = $_FILES['image']['tmp_name'];
$fp = fopen($tmpName, 'r');
$data = fread($fp, filesize($tmpName));
$data = addslashes($data);
fclose($fp);
$query = "INSERT INTO emp_register ";
$query .= "(emp_img) VALUES ('$data')";
$results = mysql_query($query, $link) or die(mysql_error());
print "Success";
}
else {
print "Error";
}
?>