Hi,
I want to fake post form with a input file type.
I found on the net this code:
function PostToHost($host, $path, $data_to_send)
{
$fp = fsockopen($host,80);
fputs($fp, "POST $path HTTP/1.1\n");
fputs($fp, "Host: $host\n");
fputs($fp, "Content-type: application/x-www-form-urlencoded\n");
fputs($fp, "Content-length: ".strlen($data_to_send)."\n");
fputs($fp, "Connection: close\n\n");
fputs($fp, $data_to_send);
while(!feof($fp))
{
echo fgets($fp, 128);
}
fclose($fp);
}
PostToHost("www.whatever.com","/cgi-bin/whatever.cgi","abc=123&def=456");
but i don't know how to modify it to send a file with this form.I know that i have to modify ");fputs($fp, "Content-type: application/x-www-form-urlencoded\n") to fputs($fp, "Content-type: multipart/form-data\n but i don't know how to modify the variable $data_to_send.
Is this possible?
Thanks