Ver Mensaje Individual
  #6 (permalink)  
Antiguo 11/03/2002, 21:23
Skynet
 
Fecha de Ingreso: enero-2002
Mensajes: 20
Antigüedad: 22 años, 3 meses
Puntos: 0
Re: simular el metodo post

Ya lo hice por si a alguien le interesa:

AQUI ESTA EL CÓDIGO, PERO MI PROBLEMA ES OTRO AHORA, LO DETALLO ABAJO:

$hostname = "www.mihost.com";
$port = 80;
$command = "http://www.mihost.com/z/";
$command.= "index.php";

/* Abro el socket y retorno su manipulador. */
$socket_handle = fsockopen( $hostname, $port, &$errno, &$errstr, 15 );

/*
* Una ves abierto el socket, compruebo de que realmente
* existe su manipulador. En caso contrario, genero un error y
* termino el script.
*/
if( !$socket_handle ) {
echo "Ocurrió el siguiente error en el socket: $errstr ($errno)<br>\n";
exit;
} else {
/*
* Con fputs() escribo en el socket, igual que si lo haría en un archivo normal.
* Aquí lo que hago es enviarle al servidor web una petición del tipo POST
* standard.
*/
fputs( $socket_handle,"POST $command?userfile=C:\z\img.jpg&name=foto HTTP/1.0\r\n\r\n" );
/*
* Recojo las respuestas del servidor y las almaceno en
* la variable $reply.
*/
while( !feof( $socket_handle ) )
$reply.= fgets( $socket_handle, 1024 );
}

CON ESTE CÓDIGO NECESITO HACER UN UPLOAD AL SERVIDOR, EL UPLOAD ME FUNCIONA DESDE UN FORMULARIO PERO DESDE ESTE SCRIPT NO, Y ESTOY ENVIANDO LAS MISMAS VARIABLES QUE DESDE EL FORMULARIO.

ALGUIEN ME PUEDE DAR UNA LUZ. parece que asi no se hace una petición POST ???

GRACIAS DENUEVO

salu2