I'm uploading an image directly to a database but I want to check its width and height and if it's not between (X, X) width and (X, X) height does not insert the data into the database and shows an error message saying that the measurements of the photo are not valid!
Any information you find important please ask! I hope I have explained myself correctly.
My code
if (isset($_POST['publicar'])) {
$nomemembro = $_POST['nomemembro'];
$cargo = $_POST['cargo'];
$name = $_FILES['imgmembro']['name'];
$target_file = basename($_FILES["imgmembro"]["name"]);
// Select file type
$imageFileType = strtolower(pathinfo($target_file, PATHINFO_EXTENSION));
// Valid file extensions
$extensions_arr = array("jpg", "jpeg", "png", "gif");
// Check extension
if (in_array($imageFileType, $extensions_arr)) {
// Convert to base64
$image_base64 = base64_encode(file_get_contents($_FILES['imgmembro']
['tmp_name']));
$image = 'data:image/' . $imageFileType . ';base64,' . $image_base64;
$query = "INSERT INTO equipa(nomeprof, foto, cargo) VALUES
('$nomemembro','" . $image . "' ,'$cargo')";
$query_run = mysqli_query($conn, $query);
echo '<script>';
echo 'alert("Membro da equipa adicionado com sucesso!")';
echo '</script>';
} else {
echo '<script>';
echo 'alert("Insira um formato de imagem válida!")';
echo '</script>';
}
}