Your Image uploaded successfully!";
}elseif ($_GET["r"] == "fail") {
echo "
F, Upload failed
";
}elseif ($_GET["r"] == "nofile") {
echo "
No file lol
";
}else{
echo "
Select an image to upload
";
}
?>
Could not connect to database";
}
if (isset($_POST['upload'])) {
// Get image name
$get_image_name = $_FILES['image']['name'];
// If image present, continue
if ($get_image_name != "") {
// Set file path for image upload
$image_path = "images/".basename($get_image_name);
$sql = "INSERT INTO swag_table (imagename) VALUES ('$get_image_name')";
// Uploading image to Table
mysqli_query($conn, $sql);
// Checking if image uploaded
if (move_uploaded_file($_FILES['image']['tmp_name'], $image_path)) {
header("Location:upload.php?r=success");
}else{
header("Location:upload.php?r=fail");
}
}else{
// No image present
header("Location:upload.php?r=nofile");
}
}
?>