I get this error everytime i hit the submit button. Everything else is submitted to the database, only the image isn't. Warning: file_get_contents(): Filename cannot be empty Any idea? Here is my code.
if(isset($_POST['consultationbutton'])){
$image = addslashes(file_get_contents($_FILES['selectedfile']['tmp_name'])); //SQL Injection defence!
$image_name = addslashes($_FILES['selectedfile']['name']);
$checkedcondition = implode(",",$_POST['skincondition']);
$checkedproduct = implode(",",$_POST['skincareinuse']);
$consultquery="INSERT INTO counsel(nric,dateconsulted,editableface,skincarecurrentlyinuse,skincondition,imagename) VALUES('132','$_POST[storedate]','{$image}','$checkedproduct','$checkedcondition','{$image_name}')";
mysqli_query($dbconn,$consultquery);
// mysqli_escape_string($dbconn,$image);
echo $checkedcondition;
echo $checkedproduct;
}
<form action="BAConsult.php" enctype="multipart/form-data" method='post'>
<img id="customerface" src="#" alt="your image" class ="consultimg"></img>
Select a file to upload: <input type="file" name="selectedfile" onchange="readURL(this);">
<input type='submit' name='consultationbutton' class='consultationbutton' value='Complete Consultation' onclick='submitclick();'>
</form>
<script>
function readURL(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
$('#customerface')
.attr('src', e.target.result)
.width(400)
.height(400);
};
reader.readAsDataURL(input.files[0]);
}
}
</script>