1 month, 5 hours daily I try to fix my problem. Asking here and there but so far seems unable to find exact solution.
<form action="connectionfile.php" method="POST" enctype="multipart/form-data">
Please Insert Image
<input type="file" name="myimage" id="myimage" accept="image/*"></input>
Enter your First Name
<input name="fname" id="fname" type="text">
</input> <input type="submit" name="upload">
</form>
Here is how I am i trying to do it using Php (connectionfile.php
)
<?php
$host = "localhost";
$dbUserName = "root";
$password = "";
$dbname = "mydb";
// Variables coming from html form
$img = file_get_contents($_FILES['myimage']['name']);
$fname = $_POST['fname'];
// Error Check if Any
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
// Connection building
$conn = mysqli_connect( $host, $dbUserName, $password, $dbname );
// inserting incoming form data into Localhost MySql Database
$sql = $conn->prepare("INSERT INTO mytable ( image_soldier , fname_soldier ) VALUES ( ? , ? )");
// Using 'b' for BLOB type parameters and 's' for string type parameters and Binding
$sql -> bind_param("bs", $img, $fname);
// Running the Sql statemnt
$sql -> execute();
?>
When i submit the form after entering name and selecting image from any directory on computer, image is not going into my database and showing in database although the name is successfully posting there.
This image shows that the name is posting in there in my Localhost but image is not posting. That shows my connection is successful to the database
Any kind of help is appreciated.