ahi va donde hago la llamada:
Código PHP:
<?php include("seguridad.php");?>
<?php
$ident= $_SESSION["insertar_piso_id"];
?>
<?
require_once("GestorImagenes.php");
$XAJAX_DIR = "../librerias/xajax/";
// Require the new xajax object
require_once($XAJAX_DIR . "xajax.inc.php");
function getProcesar_formulario($form_entrada){
$gi=new GestorImagenes();
$idInmueble= $_SESSION["insertar_piso_id"];
$result= $gi->recuperarNumero($idInmueble);
while($row= mysql_fetch_row($result)){
$numero= $row[0];
}
$numero= $numero +1;
$nombre_local= $form_entrada['archivo1'];
$mini_local= $form_entrada['archivo2'];
$nombre_nuevo= $idInmueble . "_" . $numero . "_ima";
$mini_nuevo= $idInmueble . "_" . $numero . "_mini";
$imagen_nom= $nombre_nuevo;
$mini_nom= $mini_nuevo;
$filetipe1= filetype($nombre_local);
$filetipe2= filetype($mini_local);
$tip1= $gi->archivo_tipo($nombre_local); //devuelven true o mensaje error
$tip2= $gi->archivo_tipo($mini_local);
$respuesta = new xajaxResponse();
if($tip1 && $tip2){
$res1= $gi->comprobarImagen($nombre_local,$nombre_nuevo,$mini_local,$mini_nuevo);
//$res=1;
if($res1==true){
$res2= $gi->insertarImagen($idInmueble,$numero,$imagen_nom,$mini_nom);
if($res2==1){
$mensaje="<br><strong>Los archivos se han subido con exito</strong></br>";
}else{
$error="<strong>Error al subir los archivos</strong><br/>";
}
}
else{
$error=$res1;
}
$salida_bien= $nombre_local . " || " . $mini_local . " " . $mensaje . " " .$filetipe1. " " . $filetipe2."<br/>";
$respuesta->addAppend("Layer2","innerHTML", $salida_bien);
$respuesta->addAssign("Layer3","innerHTML", "");
}
else{
//$mensaje= "Los parametros introducidos no son archivos";
$error="<br><strong>Los parametros introducidos no son archivos</strong></br>";
$salida_error= $nombre_local . " " . $mini_local . " " . $error . " ".$filetipe1." ".$filetipe2." ".$tip1." ".$tip2."<br/>";
$respuesta->addAssign("Layer3","innerHTML", $salida_error);
}/**/
$respuesta->addScript("limpiar()");
//tenemos que devolver la instanciación del objeto xajaxResponse
return $respuesta;
}
$xajax = new xajax();
$xajax->registerFunction("getProcesar_formulario");
$xajax->processRequests();
//$xajax->debugOn();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Insertar Fotos</title>
<style type="text/css">
#Layer1 {
position:absolute;
left:15px;
top:0px;
width:848px;
height:270px;
z-index:1;
}
#Layer2 {
position:absolute;
left:11px;
top:381px;
width:955px;
height:52px;
z-index:2;
font-style:normal;
color:#3366FF;
}
.Estilo1 {
font-size: 14px;
font-weight: Tahoma;
}
#Layer3 {
position:absolute;
left:14px;
top:311px;
width:957px;
height:58px;
z-index:3;
font-style:normal;
color:#CC0000;
}
</style>
<?php $xajax->printJavascript($XAJAX_DIR) ?>
</head>
<script language="Javascript">
function limpiar() {
f = document.getElementById("archivo1");
nuevoFile = document.createElement("input");
nuevoFile.id = f.id;
nuevoFile.type = "file";
nuevoFile.name = "archivo1";
nuevoFile.value = "";
nuevoFile.size=f.size;
nuevoFile.onchange = f.onchange;
nodoPadre = f.parentNode;
nodoSiguiente = f.nextSibling;
nodoPadre.removeChild(f);
(nodoSiguiente == null) ? nodoPadre.appendChild(nuevoFile):
nodoPadre.insertBefore(nuevoFile, nodoSiguiente);
f = document.getElementById("archivo2");
nuevoFile = document.createElement("input");
nuevoFile.id = f.id;
nuevoFile.type = "file";
nuevoFile.name = "archivo2";
nuevoFile.value = "";
nuevoFile.size=f.size;
nuevoFile.onchange = f.onchange;
nodoPadre = f.parentNode;
nodoSiguiente = f.nextSibling;
nodoPadre.removeChild(f);
(nodoSiguiente == null) ? nodoPadre.appendChild(nuevoFile):
nodoPadre.insertBefore(nuevoFile, nodoSiguiente);
}
function redireccion(){
document.location='iu_insertarPisos.php' ;
}
</script>
<body>
<form id="formulario" name="formulario" method="POST" enctype="multipart/form-data">
<div id="Layer1">
<p class="Estilo1"><strong>Las imagenes se deben adjuntar por parejas </strong></p>
<p><strong><span class='Estilo1'>La referencia del inmueble introducido es <?php echo $ident; ?></span></strong></p>
<p><strong><span class='Estilo1'>Inserta el nombre de la imagen en tamaño normal</span></strong></p>
<input name="archivo1" type="file" id="archivo1" size="100"/>
<p><strong><span class='Estilo1'>Inserta el nombre de la imagen en tamaño miniatura</span></strong></p>
<input name="archivo2" type="file" id="archivo2" size="100"/><br/><br/>
<input type="button" value="Subir archivos" onclick="xajax_getProcesar_formulario(xajax.getFormValues('formulario'))"/>
<input type="button" value="Terminar" onclick="redireccion()"/>
</div>
<div id="Layer2"></div>
<div id="Layer3"></div>
</form>
</body>
</html>