/
home2
/
reumatologia
/
public_html
/
admin
/
Upload File
HOME
<?php require_once('../inc_library.php'); /* obtenemos datos enviados */ $IdCategoriaPpal = intval($_REQUEST['IdCategoriaPrincipal']); $arrCategoriasSecundarias = $_REQUEST['IdCategoria']; $Fecha = strval($_REQUEST['Fecha']); $Hora = strval($_REQUEST['Hora']); $Titulo = strval($_REQUEST['Titulo']); $Copete = strval($_REQUEST['Copete']); $Cuerpo = strval($_REQUEST['Cuerpo']); $FechaHasta = strval($_REQUEST['FechaHasta']); $Ubicacion = strval($_REQUEST['Ubicacion']); $Direccion = strval($_REQUEST['Direccion']); $Web = strval($_REQUEST['Web']); $WebNombre = strval($_REQUEST['WebNombre']); $Email = strval($_REQUEST['Email']); $Video = strval($_REQUEST['Video']); $Unisar = intval($_REQUEST['Unisar']); $IGG4 = intval($_REQUEST['IGG4']); $arrKeywords = $_REQUEST['keyword']; $Submit = (isset($_REQUEST['Submitted'])); /* declaramos e instanciamos variables necesarias */ $err = 0; $oEvento = new Evento(); $oEventos = new Eventos(); $oCategorias = new Categorias(); $oEventoArchivos = new EventoArchivos(); $oEventosCategorias = new EventosCategorias(); $oKeywords = new Keywords(); /* definimos cadena a mandar por get */ /* validaciones... */ if ($IdCategoriaPpal == '') $err |= 1; if ($Fecha == '') $err |= 2; if ($Titulo == '') $err |= 4; /* si no hay errores... */ if ($err == 0) { $Imagen = $_FILES['Imagen-1']; /* si no hay errores... */ if ($Imagen['name'] != '') { if ($Imagen['error'] != 1) { $oUpload = new Image ( $Imagen['name'], $Imagen['tmp_name'], $Imagen['size'], $Imagen['type'], array(Evento::PathImageBig, Evento::PathImageThumb), array('jpg', 'jpeg', 'gif', 'png'), array(1200, 1200), array(600, 600), array('Resize', 'Adaptive'), 100 ); } } if (!$oUpload || $oUpload->UploadImage()) { $oEvento->IdCategoria = $IdCategoriaPpal; $oEvento->Fecha = $Fecha; $oEvento->Hora = $Hora; $oEvento->Titulo = $Titulo; $oEvento->Copete = $Copete; $oEvento->Cuerpo = $Cuerpo; $oEvento->FechaHasta = $FechaHasta; $oEvento->Ubicacion = $Ubicacion; $oEvento->Direccion = $Direccion; $oEvento->Web = $Web; $oEvento->WebNombre = $WebNombre; $oEvento->Email = $Email; $oEvento->Video = $Video; $oEvento->Unisar = $Unisar; $oEvento->IGG4 = $IGG4; $oEvento->Imagen = $oUpload ? $oUpload->GetNombre() : ''; /* creamos el registro */ $oEvento = $oEventos->Create($oEvento); foreach ($arrCategoriasSecundarias as $IdCategoria) { $oEC = new EventoCategoria(); $oEC->IdEvento = $oEvento->IdEvento; $oEC->IdCategoria = $IdCategoria; $oEventosCategorias->Create($oEC); } $arrArchivos = $_FILES['Archivo']; $count = 0; foreach($_FILES['Archivo']['tmp_name'] as $key => $tmp_name) { if ($_FILES['Archivo']['name'][$key] == '') continue; $oUpload = new Up ( $key.$_FILES['Archivo']['name'][$key], $_FILES['Archivo']['tmp_name'][$key], $_FILES['Archivo']['size'][$key], $_FILES['Archivo']['type'][$key], Evento::PathFile ); $Nombre = $_REQUEST['NombreArchivo'][$count]; if ($Nombre == '') $Nombre = $_FILES['Archivo']['name'][$key]; if ($oUpload->UploadFile()) { $oEventoArchivo = new EventoArchivo(); $oEventoArchivo->IdEvento = $oEvento->IdEvento; $oEventoArchivo->Nombre = $Nombre; $oEventoArchivo->Archivo = $oUpload->GetNombre(); /* creamos el registro */ $oEventoArchivo = $oEventoArchivos->Create($oEventoArchivo); } $count++; } if ($arrKeywords) { foreach ($arrKeywords as $keyword) { $oKeyword = new Keyword(); $oKeyword->IdEvento = $oEvento->IdEvento; $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 la imagen."))); } } else { header('Content-type: application/json'); echo json_encode(array("Success" => false, "Error" => utf8_encode($err. "Error al crear el evento."))); } ?>