You are here: Try to get a file from a server by PHP « PHP Programming Language « IT news, forums, messages
Try to get a file from a server by PHP

Posted by NurAzije on 10/21/05 18:00

I am trying to make afunction to get information from one file and
print it or put it in an array, the problem in headers I can't figure
that it is giving me this:
********
HTTP/1.1 400 Bad Request Date: Fri, 21 Oct 2005 14:48:06 GMT Server:
Apache Connection: close Content-Type: text/html; charset=iso-8859-1
Bad Request
Your browser sent a request that this server could not understand.

Request header field is missing colon separator.

Host=www.imtec.ba
********
My code is :
*********
<?
function getFile($host,$file)
{
$request="GET $file HTTP/1.0\r\n"; // This is the path part of the
link
$request.="Host=$host\r\n\r\n"; // This is the server part of the
link

// Now let's try connecting:
$fp=fsockopen($host, 80, $errno, $errstr, 30);

// Let's see if we made it
if (!$fp)
{
return(false);
}
else
{
// If we made it, let's send the request:
fputs($fp, $request);

while (!feof($fp))
{
$response.=fgets($fp, 128);
}
fclose($fp);
return($response);
}
}
echo getFile("www.imtec.ba","index.php");
?>
*********
Any help, what is wrong..
Thank you

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация