I try to use lazyload but it's load image poorly so I want to use thumbnail so it can load faster and save bandwidth. There's a lot of source code that I can use for reducing image data and resolution, I am trying to merge it with my upload.php but it doesn't work, I'm trying move_upload_path and copy below move_upload_path, it work and storing in more than one folder but it's not showing up on my MySQL database. Here's my code (I'm not using the new one that storing in multiple folder path)
<?php
echo "<pre>";
print_r($_FILES['my_image']);
echo "</pre>";
$img_name = $_FILES['my_image']['name'];
$img_size = $_FILES['my_image']['size'];
$tmp_name = $_FILES['my_image']['tmp_name'];
$error = $_FILES['my_image']['error'];
if ($error === 0) {
if ($img_size > 125000000) {
$em = "Sorry, your file is too large.";
header("Location: index1.php?error=$em");
}else {
$img_ex = pathinfo($img_name, PATHINFO_EXTENSION);
$img_ex_lc = strtolower($img_ex);
$allowed_exs = array("jpg", "jpeg", "png");
if (in_array($img_ex_lc, $allowed_exs)) {
$new_img_name = uniqid("IMG-", true).'.'.$img_ex_lc;
$img_upload_path = 'uploads/'.$new_img_name;
move_uploaded_file($tmp_name, $img_upload_path);
$sql = "INSERT INTO images(image_url)
VALUES('$new_img_name')";
mysqli_query($conn, $sql);
header("Location: index.php");
}else {
$em = "You can't upload files of this type";
header("Location: index.php?error=$em");
}
}
}else {
$em = "unknown error occurred!";
header("Location: index.php?error=$em");
}