I am having issues storing a .JPG
image in my MySQL database. I am using the PHP code below to store it into the database (in long blob form). My code appears to be completely error free and every thing seems to act as it should aside from the fact that the image is only stored in what appears to be 36 B size on PHPMyAdmin.
I would expect the image to be much larger (22 MB supposedly).
<?php
require '../FirstWebsite/CommonFunctions.php';
DB_Connect();
$dblink = DB_Connect();
?>
<html>
<body>
<form method="post" enctype="multipart/form-data">
<br/>
<input type="file" name="selectImage">
<br/>
<input type="submit" name="submitImage" value="submit">
</form>
<?php
if(isset($_POST['submitImage'])){
if(getimagesize($_FILES['selectImage']['tmp_name'])==FALSE){
echo 'please select an actual image';
}
else{
$getImage = mysqli_real_escape_string($dblink, $_FILES['selectImage']['tmp_name']);
$name = mysqli_real_escape_string($dblink, $_FILES['selectImage']['name']);
$image = base64_encode($getImage);
saveImage($name, $image, $dblink);
}
}
function saveImage($name, $image, $dblink){
$query = "INSERT INTO trialtable2 (caption, actualpicture) VALUES ('$name','$image')";
$queryCheck = mysqli_query($dblink, $query);
if($queryCheck == TRUE){
echo '<br/> uploaded';
}
else{
echo '<br/> not uploaded';
}
}
?>
</body>
</html>
what I have done
attempted uploading
.jpeg
.JPG
.jpg
(same but still...).tif
.png
file_upload = on
(or whatever) is already on inphp.ini
it is a long blob type in the data base table
Supposedly storing images in a database is no the way to go however this is what I am working with for the time being.
versions
- wamp: 2.5
- apache: 2.4.9
- mysql: 5.6.17
- php: 5.5.12
I believe that this question is not a replica as I haven't been able to find an answer elsewhere. If I am doing something incorrectly feel free to let me know as I am still new to the community.