Ver Mensaje Individual
  #5 (permalink)  
Antiguo 01/10/2008, 04:23
Avatar de c4_esp_VR
c4_esp_VR
 
Fecha de Ingreso: julio-2008
Mensajes: 24
Antigüedad: 15 años, 10 meses
Puntos: 0
Respuesta: Comprobar archivos existentes FTP

Por el momento he conseguido enviar los datos necesarios via AJAX y método GET a otra url y esta se visualize en mi página "principal" de la siguiente manera.

Código PHP:
<script language="javascript">

function nuevoAjax(){
var xmlhttp=false;
 try {
  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
 } catch (e) {
  try {
   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (E) {
   xmlhttp = false;
  }
 }

if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
  xmlhttp = new XMLHttpRequest();
}
return xmlhttp;
}



function cargarContenido(){
var t1, t2, contenedor;
contenedor = document.getElementById('contenedor');
t1 = document.getElementById('archivo').value;
t2 = document.getElementById('hiddenField').value;
ajax=nuevoAjax();
ajax.open("GET", "PruebaAJAXFTP.php?t1="+t1+"&t2="+t2,true);
ajax.onreadystatechange=function() {
if (ajax.readyState==4) {
contenedor.innerHTML = ajax.responseText
}
}
ajax.send(null)
}
</script>

<form onSubmit="cargarContenido(); return false">
        <input name="hiddenField" type="hidden" value="<?php echo $_GET["dir"];?>" id="hiddenField"/>
        <input name="archivo" type="file" id="archivo" />
         <input type="submit" value="Upload" onPress="cargarContenido()" />
</form>

<div id="contenedor">div contenedor</div>
El código de la url PruebaAJAXFTP.php es el siguiente:

Código PHP:
<?
    
include('includes/ftpfunc.php'); //Incluye el archivo de funciones    
    
$id_ftp=ConectarFTP();
    
$ruta=ObtenerRuta();

    
$archivo $_GET["t1"];
    
$dir $ruta.'/'.$_GET["t2"].'/'.$archivo;
    
    if(
file_exists('.'.$dir))
    {
        echo 
'El fichero existe';
    }
    else
    {
    }    
    
ftp_quit($id_ftp);
?>
Donde si el fichero existe saca por pantalla 'El fichero existe'.

Primeramente estoy ilusionado por ver como es esta maravilla que no hace falta que recargue la página de nuevo es una pasada...

Pero ahora como hago para que el usuario seleccione SI o NO y luego suba el archivo via FTP ya que no sé como pasar variables de la url PruebaAJAXFTP a la url principal... estoy echo un lio

Gracias por la ayuda de antemano.