Ver Mensaje Individual
  #1 (permalink)  
Antiguo 11/01/2004, 01:57
jmaribau
 
Fecha de Ingreso: enero-2004
Mensajes: 235
Antigüedad: 20 años, 4 meses
Puntos: 0
Pregunta Popup que envia formulario via POST al padre para ejecutar script php

Cómo hacer esto?

Una ventana padre abre un popup. Este popup contiene un formulario via POST ( 1 input type, 1 input file, 1 input submit), el action del formulario es un script php. En el momento de hacer submit, se tendria que enviar la informacion a la ventana padre ejecutandose el script en el padre y cerrarse el popup.

He creado el popup, el formulario envia la información al script php, pero lo ejecuta en el popup y no en la ventana padre.

Lo que queda es cómo hacer que el popup apunte al padre para enviarle el formulario via post.

Aqui teneis el código:
Código PHP:
<html>
<head>
<title> New Document </title>
</head>
<body>

<?php

if (isset($_GET['p'])) {
    
?>
    <form method='post' action='upload2.php' enctype="multipart/form-data">
    <input type='file' name='file' id='file'>
    Escribir algo <input type='text' name='text' id='text'>
    <br>
    <input type='submit' name='submit' value='Ok' Onclick=''>
    </form>
    <?php
    
exit;
}

if (isset(
$_FILES['file'])) {
    
$fileupload=$_FILES['file']['tmp_name'];
    
$destination=$_FILES['file']['name'];
    if (
is_uploaded_file($_FILES['file']['tmp_name'])) {
        if (
move_uploaded_file($fileupload,$destination)) print("<br><br>Guardat correctament a: $destination");
        else print(
'No guardat, error');
    }
}

if (isset(
$_POST['text'])) {
    echo 
'Este es el texto:'.$_POST['text'];
    exit;
}

?>


<a href='upload2.php' Onclick="window.open('upload2.php?p=','new','toolbar=no,width=300,height=300,status=no,scrollbars=no,resize=no,menubars=no'); return false;">click</a>
</body>
</html>
Espero antentamente vuestras respuestas. Un saludo.