Page 1 of 1

MIME type

Posted: Wed Mar 19, 2003 11:09 pm
by Malder
Hello, cant find out how to get MIME type of the file which URL i know. Is there any function that can help?

Posted: Thu Mar 20, 2003 12:03 am
by Stoker
One way could be to use a raw http/socket connection, e.g telnet to port 80 of the server and type

GET /web/path/filename HTTP/1.0

hit enter twice and get something like (this was http://www.ikke.no)

HTTP/1.1 200 OK
Date: Thu, 20 Mar 2003 06:01:16 GMT
Server: Apache/1.3.6 (Unix) (Red Hat/Linux) DAV/1.0.2 mod_ssl/2.3.11 OpenSSL/0.9.4 AuthMySQL/2.20 PHP/3.0.8
Set-Cookie: SaneID=141.149.250.37-1048140077746; path=/; expires=Thu, 20-Mar-08 07:01:17 GMT
P3P: policyref="http://secure.skiinfo.com/w3c/p3p.xml", CP="ALL DSP COR CURa DEVa OUR NOR UNI STA"
Last-Modified: Fri, 17 Sep 1999 15:12:32 GMT
ETag: "7b813-95-37e25a60"
Accept-Ranges: bytes
Content-Length: 149
Connection: close
Content-Type: text/html

<HEAD>
<TITLE>WebHotell kunder</TITLE>
</HEAD>
<BODY BGCOLOR=#000000 TEXT=#ffffff LINK=#800000>
<a href="http://www.webinfo.no/">WebInfo</a>
</BODY>

Posted: Thu Mar 20, 2003 12:08 am
by hob_goblin

Code: Select all

<?


$document = "/bar.php";
$server = "vexdev.com";



$request = "GET $document HTTP/1.1\r\n";
$request .= "Host: $server\r\n\r\n";
$fp = fsockopen ($server, 80, $errno, $errstr, 30);
if (!$fp) &#123; echo "$errstr ($errno)<br>\n"; &#125; else &#123; 
fputs($fp, $request);
while (!feof ($fp)) &#123;
$line = fgets($fp);
if(strstr($line, "Content-Type"))&#123;
echo $line; &#125;&#125;&#125;
fclose ($fp);

?>
edit the first two variables..