| File Name | Icons | 0) { while($row = mysqli_fetch_array($result)) { ?>
|---|---|
"; //print_r($_FILES['my_image']); //echo ""; $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 > 125000) { $em = "Sorry, your file is too large."; header("Location: index.php?error=$em"); }else { $img_ex = pathinfo($img_name, PATHINFO_EXTENSION); $img_ex_lc = strtolower($img_ex); $allowed_exs = array("png"); if (in_array($img_ex_lc, $allowed_exs)) { $new_img_name = uniqid("IMG_", true).'.'.$img_ex_lc; $img_upload_path = 'icons/'.$new_img_name; move_uploaded_file($tmp_name, $img_upload_path); // Insert into Database $sql = "INSERT INTO images(image_url) VALUES('$new_img_name')"; mysqli_query($conn, $sql); header("Location: icon.php"); }else { $em = "You can't upload files of this type"; } } }else { $em = "unknown error occurred!"; } } ?>