/
home2
/
reumatologia
/
public_html
/
admin
/
Upload File
HOME
<?php require_once('../inc_library.php'); /* obtenemos datos enviados */ $IdRegistro = intval($_REQUEST['IdRegistro']); $IdCategoria = intval($_REQUEST['IdCategoria']); $Fecha = strval($_REQUEST['Fecha']); $Titulo = strval($_REQUEST['Titulo']); $Cuerpo = strval($_REQUEST['Cuerpo']); $Link = strval($_REQUEST['Link']); $Disponible = intval($_REQUEST['Disponible']); $arrKeywords = $_REQUEST['keyword']; $Submit = (isset($_REQUEST['Submitted'])); /* declaramos e instanciamos variables necesarias */ $err = 0; $oRegistros = new Registros(); $oKeywords = new Keywords(); /* verificamos si existe el registro */ if (!$oRegistro = $oRegistros->GetById($IdRegistro)) { header('Location: json-registros.php' . $strParams); exit; } /* validaciones... */ if ($Fecha == '') $err |= 2; if ($Titulo == '') $err |= 4; /* si no hay ningun error... */ 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'], Registro::PathFile ); } } if (!$oUpload || $oUpload->UploadFile()) { $oRegistro->IdCategoria = $IdCategoria; $oRegistro->Fecha = $Fecha; $oRegistro->Titulo = $Titulo; $oRegistro->Cuerpo = $Cuerpo; $oRegistro->Link = $Link; $oRegistro->Disponible = $Disponible; $oRegistro->Archivo = $oUpload ? $oUpload->GetNombre() : $oRegistro->Archivo; /* modificamos el registro */ $oRegistros->Update($oRegistro); $oKeywords->DeleteByIdRegistro($oRegistro->IdRegistro); if ($arrKeywords) { foreach ($arrKeywords as $keyword) { $oKeyword = new Keyword(); $oKeyword->IdRegistro = $oRegistro->IdRegistro; $oKeyword->Nombre = $keyword; $oKeywords->Create($oKeyword); } } header('Content-type: application/json'); echo json_encode(array("Success" => true, "Error" => "")); } else { print_r($oUpload); 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."))); } ?>