I am trying to add a picture upload for a project that i am currently doing, but whenever i try this it does not display correctly on the page. But if i add the picture using phpMyadmin it displays fine on the webpage. To display the image on the page i am using this code.
<img src="data:image/jpeg;base64,'. base64_encode( $row['review_picture'] ). '" style="height: 150px; width: 150px;" />
For the upload i am working on, it involves a form, with other inputs beside the file upload, but the code below, is in its basic form
<form action="new_review.php" method="post" name="myForm">
<label>Review Picture: </label><input type="file" name="review_picture" id="review_picture">
But the part which i am really struggling on is the page, which it is posted to.
$data = file_get_contents('$_POST[review_picture]');
$data = base64_encode($data);
mysqli_query($connection_Var,"INSERT INTO review(review_picture) VALUES ('$base64') or die (mysql_error());
header( 'Location: ../index.php');
$connection_Var = mysqli_connect("localhost","root","","review_db");
echo "Failed to connect to MySQL: " . mysqli_connect_error();
I have tried many different ways round this, what ever i try i can't quite get the hang of it, and tbf it the last piece of code is a bit of rough guess. I would be really grateful for any help.