Exemplo n.º 1
0
}
if (isset($_FILES['immagine-slider'])) {
    if ($_FILES['immagine-slider']['type'] != "image/jpg" && $_FILES['immagine-slider']['type'] != "image/jpeg") {
        header("location: admin_home.php?msg=invalid-file");
    } else {
        if (!preg_match('/\\s/', $_FILES['immagine-slider']['name'])) {
            if (!file_exists("./images/home-slider/" . $_FILES['immagine-slider']['name'])) {
                $tempPos = $_FILES['immagine-slider']['tmp_name'];
                $destPos = "./images/home-slider/" . $_FILES['immagine-slider']['name'];
                include 'models/SimpleImage.php';
                $image = new SimpleImage();
                $image->load($_FILES['immagine-slider']['tmp_name']);
                $image->resize($width_image_slider, $height_image_slider);
                $image->save("./images/home-slider/" . $_FILES['immagine-slider']['name']);
                //move_uploaded_file($tempPos, $destPos);
                require_once "models/dbcontroller.php";
                if (dbcontroller::addHomeSlider($_FILES['immagine-slider']['name'])) {
                    header("location: admin_home.php?msg=success");
                } else {
                    header("location: admin_home.php?msg=errordb");
                }
            } else {
                header("location: admin_home.php?msg=name-already-exist");
            }
        } else {
            header("location: admin_home.php?msg=error-invalid-name");
        }
    }
} else {
    header("location: admin_home.php");
}