Esempio n. 1
0
<?php

if ($_POST['action'] == "save") {
    if (empty($_POST['item'])) {
        // upload background
        if (!empty($_FILES['file-background']['name'])) {
            $str = ImagemHelper::upload($_POST['dir'], "topo-home-background", $_POST['next-item'], $_FILES['file-background']);
            $str = explode("*;*", $str);
            $_POST['background'] = $str[1];
        }
        //
        preparaBotao();
        $res = ConfiguracaoController::insertTopo($_POST);
        if ($res) {
            header("Location: site-topo-home?lang=" . $_POST['lang']);
            exit;
        } else {
            die("ERRO");
        }
    } else {
        // upload background
        if (!empty($_FILES['file-background']['name'])) {
            $str = ImagemHelper::upload($_POST['dir'], "topo-home-background", $_POST['item'], $_FILES['file-background']);
            $str = explode("*;*", $str);
            $_POST['background'] = $str[1];
        } elseif ($_POST['delete-background'] == 1) {
            ImagemHelper::delete("img/" . $_POST['dir'] . "/" . $_POST['background']);
            $_POST['background'] = "";
        }
        //
        preparaBotao();