> Oops, I forgot to mention the most important part...
> I need to get the MIME-type (or something that can identify the
> file-extension) from a file ALREADY on the server, not posted through a
> form.
> I.e. How do I get the MIME-type of "tobias.zip" in my folder?
>
> I already know how to get the MIME-type from a form...
> Thanks for the nice snippets though. They might come in handy in the
future.
Just knocked this together. It doesn't confirm whether or not the files are
actually valid MIME types (like .zip). For instance, you could upload a
text files, rename it to .zip and it will list it (if you change the
following $required_types variable I've put in here:
__________________________
<html>
<head>
<title>Looking MIME types?</title>
</head>
<body>
Here is a listing of the directory I want to be looking in and all of the
files in it. If the files are listed below, they're the ones I want to
know.
<ul>
<?
$directory = "/path/to/directory/";
$dir = opendir($directory);
/* Change to the types you want */
$required_types = array(".gif",".jpg");
while($MIMEfile = readdir($dir)) {
$extension = strrchr($MIMEfile,'.');
if(($MIMEfile != ".") && ($MIMEfile != "..") &&
(in_array($extension,$required_types))) {
$filetype = filetype($MIMEfile);
echo "<li>$MIMEfile";
}
}
?>
</ul>
</body>
</html>
________________________
Note that this probably isn't the best way to go about things, but I've had
a quick root through the file() functions, and could find nothing (though I
didn't look too hard) quick and easy.
Have fun.
James.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]