<?php $pdfSubmit = filter_input(INPUT_POST, 'pdfSubmit', FILTER_SANITIZE_STRING); if ($pdfSubmit) { if (!isset($_SESSION['gift_form'])) { $result = uploadPDF($db, (int) $_SESSION['user_id'], $_FILES['pdf']['name'], $_FILES['pdf']['size'], $_FILES['pdf']['tmp_name'], $_FILES['pdf']['type']); if ($result === true) { $success = 'Gutschein erfolgreich hochgeladen'; } else { $errors = $result; } $_SESSION['gift_form'] = 1; } else { unset($_SESSION['gift_form']); header('Location: /dashboard/gifts'); } } $deleteSubmit = filter_input(INPUT_POST, 'deleteSubmit', FILTER_SANITIZE_STRING); if ($deleteSubmit) { if (!isset($_SESSION['gift_form'])) { $giftId = (int) filter_input(INPUT_POST, 'giftId'); $result = deletePDF($db, $giftId); if ($result) { $deleteSuccess = 'Gutschein wurde erfolgreich gelöscht!'; } else { $error = 'Gutschein konnte nicht gelöscht werden.'; } $_SESSION['gift_form'] = 1; } else { unset($_SESSION['gift_form']); header('Location: /dashboard/gifts');
$ruta = $_POST['ruta']; $bitacora = $_POST['bitacora']; $bitacoraex = explode(',', $bitacora); //$destino=$_POST['rutaPdf']; if ($file['type'] == 'application/pdf') { function uploadPDF($filePDF, $ruta) { $temp = $filePDF['tmp_name']; $filename = $filePDF['name']; $rutaex = explode("/", $ruta); $path = '/' . $rutaex[1] . '/' . $rutaex[2] . '/' . $rutaex[3] . '/' . $rutaex[4] . '/' . $rutaex[5] . '/' . $rutaex[6] . '/'; $destination = $path . $filename; $uploaded = move_uploaded_file($temp, $destination); if ($uploaded) { $success = array('error' => 'no', 'pdf' => 'si', 'ruta' => '' . $destination); return $success; } else { $error = array('error' => 'si', 'errorMsg' => 'No se pudo subir el archivo PDF'); return $error; } } //End uploadt $response = uploadPDF($file, $ruta); echo json_encode($response); } else { $response = array('error' => 'badtype', 'errorMsg' => 'Tipo de archivo no valído.'); echo json_encode($response); } $qry = mssql_query("EXEC spSalBitacoraXML 'GAS'," . $bitacoraex[0] . ",'" . $bitacoraex[1] . "','" . $destination . "','" . utf8_decode($error["errorMsg"]) . "'"); } }