Example #1
0
if ($_POST['action'] == "save") {
    if (empty($_POST['item'])) {
        // upload foto
        if (!empty($_FILES['file-foto']['name'])) {
            $str = ImagemHelper::upload($_POST['dir'], "depoimento-foto", $_POST['next-item'], $_FILES['file-foto']);
            $str = explode("*;*", $str);
            $_POST['foto'] = $str[1];
        }
        // upload logo
        if (!empty($_FILES['file-logo']['name'])) {
            $str = ImagemHelper::upload($_POST['dir'], "depoimento-logo", $_POST['next-item'], $_FILES['file-logo']);
            $str = explode("*;*", $str);
            $_POST['logo'] = $str[1];
        }
        //
        $res = ConfiguracaoController::insertDepoimento($_POST);
        if ($res) {
            header("Location: site-depoimentos?lang=" . $_POST['lang']);
            exit;
        } else {
            die("ERRO");
        }
    } else {
        // upload foto
        if (!empty($_FILES['file-foto']['name'])) {
            $str = ImagemHelper::upload($_POST['dir'], "depoimento-foto", $_POST['item'], $_FILES['file-foto']);
            $str = explode("*;*", $str);
            $_POST['foto'] = $str[1];
        } elseif ($_POST['delete-foto'] == 1) {
            ImagemHelper::delete("img/" . $_POST['dir'] . "/" . $_POST['foto']);
            $_POST['foto'] = "";