/
home2
/
reumatologia
/
public_html
/
admin
/
Upload File
HOME
<?php ini_set('display_errors', '1'); ini_set('display_startup_errors', '1'); error_reporting(E_ALL); require_once('../inc_library.php'); /* obtenemos datos enviados */ $Fecha = strval($_REQUEST['Fecha']); $Nombre = strval($_REQUEST['Nombre']); $Link = strval($_REQUEST['Link']); $IdEnfermedad = intval($_REQUEST['IdEnfermedad']); $Disponible = intval($_REQUEST['Disponible']); $IGG4 = intval($_REQUEST['IGG4']); $arrKeywords = $_REQUEST['keyword']; $Submit = (isset($_REQUEST['Submitted'])); /* declaramos e instanciamos variables necesarias */ $err = 0; $oGuia = new Guia(); $oGuias = new Guias(); $oKeywords = new Keywords(); /* definimos cadena a mandar por get */ /* validaciones... */ if ($Fecha == '') $err |= 2; if ($Nombre == '') $err |= 4; /* si no hay errores... */ if ($err == 0) { $Archivo = $_FILES['Archivo']; /* si no hay errores... */ if ($Archivo['name'] != '') { if ($Archivo['error'] != 1) { $oUpload = new Up ( $Archivo['name'], $Archivo['tmp_name'], $Archivo['size'], $Archivo['type'], Guia::PathFile ); } } if (!$oUpload || $oUpload->UploadFile()) { $oGuia->Fecha = $Fecha; $oGuia->Nombre = $Nombre; $oGuia->IdEnfermedad = $IdEnfermedad; $oGuia->Disponible = $Disponible; $oGuia->IGG4 = $IGG4; $oGuia->Link = $Link; $oGuia->Archivo = $oUpload ? $oUpload->GetNombre() : ''; /* creamos el registro */ if ($oGuia = $oGuias->Create($oGuia)) { if ($arrKeywords) { foreach ($arrKeywords as $keyword) { $oKeyword = new Keyword(); $oKeyword->IdGuia = $oGuia->IdGuia; $oKeyword->Nombre = $keyword; $oKeywords->Create($oKeyword); } } } header('Content-type: application/json'); echo json_encode(array("Success" => true, "Error" => "")); } else { header('Content-type: application/json'); echo json_encode(array("Success" => false, "Error" => utf8_encode($err. "Error al procesar el archivo."))); } } else { header('Content-type: application/json'); echo json_encode(array("Success" => false, "Error" => utf8_encode($err. "Error al crear el evento."))); } ?>