function AlteraCategoria($id) { $categoria = new Categorias(); $nome = null; $imagem = null; if (isset($_POST['CAT_NOME'])) { $nome = $_POST['CAT_NOME']; } if (isset($_FILES['CAT_FILE']) && $_FILES['CAT_FILE']['size'] > 0) { $_file = $_FILES['CAT_FILE']; if ($_file["error"] > 0) { header("location: ../categorias.php?status=error"); return; } $c = GetCategoria($id); if (file_exists("../" . $_SESSION['categoriasImagePrefix'] . $c['imagem'])) { $ret = Arquivos::RemoveFile("../" . $_SESSION['categoriasImagePrefix'] . $c['imagem']); if ($ret == FALSE) { header("location: ../categorias.php?status=error"); return; } } $imagem = Arquivos::UpdateArquivo("../" . $_SESSION['categoriasImagePrefix'], $_file); } $result = $categoria->AlteraCategoria($id, $nome, $imagem); if ($result == TRUE) { header("location: ../categorias.php?status=success"); } else { header("location: ../categorias.php?status=error"); } return; }