Ver Mensaje Individual
  #10 (permalink)  
Antiguo 12/11/2012, 14:07
Avatar de emprear
emprear
Colaborador
 
Fecha de Ingreso: junio-2007
Ubicación: me mudé
Mensajes: 8.388
Antigüedad: 16 años, 10 meses
Puntos: 1567
Respuesta: Utlizar Iframe para simular AJAX

Cita:
Iniciado por koolj Ver Mensaje
Lo logre ......................Gracias a todos en especial a emprear me sirvió mucho tu ejemplo y si te fijas bien en el formulario tiene onSubmit="iniciar();" que muestra el gif.

Bueno les dejo el código completo funcionando y de nuevo muchas gracias

La Página principal

Código HTML:
<!DOCTYPE html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Demo de subida</title>
<script>
function iniciar(){
    document.getElementById('carga').style.visibility = 'visible';
}

function detener(valor){
	if(valor == 'stop'){
		document.getElementById('carga').style.visibility = 'hidden';
	}
}
</script>
<style type="text/css">
#carga{	
	visibility:hidden;
}
</style>
</head>

<body>
<form name="form1" method="post" action="archivos.php" enctype="multipart/form-data" target="la_otra_pagina" onSubmit="iniciar();">
  <table width="50%" border="0">
    <tr>
      <td>Nombre:</td>
      <td><input type="text" name="txtNombre" id="textfield"></td>
    </tr>
    <tr>
      <td>Foto:</td>
      <td>
      <input type="file" name="txtFoto" id="fileField"></td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td><input type="submit" value="mostrar"></td>
    </tr>    
  </table>
</form>
<div id="carga"><img id="cargando" src="load.gif" width="220" height="19" alt="load"></div>
<iframe name="la_otra_pagina" src="archivos.php" frameborder="0"></iframe>
</body>
</html> 
El código]de archivos.php

Código PHP:
    if($_POST)
    {            
        
$nombre $_POST['txtNombre'];
        
$nombre_archivo $_FILES['txtFoto']['name'];        
        
$origen $_FILES['txtFoto']['tmp_name'];        
        
$destino "subidas/".$nombre_archivo;        
        if(
move_uploaded_file($origen,$destino))
        {
            echo 
'
            <script>
                parent.detener("stop");
            </script>
            '
;
        }
    } 
mil disculpas @koolj, si ahi está, no le di al scroll del code y se me pasó por alto.
Te agrego, en lugar de hacerle un hidden al div carga, podrías hacerlo un innerHTML = '"Archivo subido correctamente";

Saludos
__________________
La voz de las antenas va, sustituyendo a Dios.
Cuando finalice la mutación, nueva edad media habrá
S.R.