im develop website using xampp localhost. I want to add image using phpmyadmin but i can't add it..the image can display in phpmyadmin but can't appear on my website..is it any wrong with my coding in php?
$host="localhost"; // Host name
$username="root"; // Mysql username
$password=""; // Mysql password
$db_name="MMDB"; // Database name
$tbl_name="artist"; // Table name
// Create connection
$conn = mysqli_connect($host, $username, $password, $db_name);
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
$Name=$_POST['Name'];
$Hometown=$_POST['Hometown'];
$Income=$_POST['Income'];
$Image=$_POST['Image'];
//file =$_FILES['image']['tmp_name'];
$Video=$_POST['Video'];
$sql = "INSERT INTO $tbl_name(Name, Hometown, Income, Image, Video)
VALUES ('$Name', '$Hometown','$Income','$Image','$Video')";
if (mysqli_query($conn, $sql)) {
include 'admin.php';
} else {
echo "x";
}
mysqli_close($conn);
?>
whats the code for add image in folder?
// where should i insert this code "> $image = $_FILES["image"]["name"]; $uploadedfile = $_FILES['image']['tmp_name']; if ($image) { $filename = stripslashes($_FILES['image']['name']);
/* Ensure the file is JPG/PNG */
if (($_FILES['image']['type'] != "image/jpg") && ($_FILES['image']['type'] != "image/jpeg") && ($_FILES['image']['type'] != "image/png")) { $error_status = 2; $error_message = "File uploaded was not a JPG or PNG file."; }
else {
/* Ensure the file is less than 10MB */
$size = filesize($_FILES['image']['tmp_name']);
if ($size > (MAX_SIZE * 1024)) { $error_status = 3; $error_message = "File uploaded needs to be less than 10MB."; }
else {
$extension = "jpg";
if(($_FILES['image']['type'] == "image/jpg") || ($_FILES['image']['type'] == "image/jpeg")) { $uploadedfile = $_FILES['image']['tmp_name']; $src = imagecreatefromjpeg($uploadedfile); }
else if (($_FILES['image']['type'] == "image/png")) { $extension = "png"; $uploadedfile = $_FILES['image']['tmp_name']; $src = imagecreatefrompng($uploadedfile); }
$img_mime_type = $_FILES['image']['type'];