Re: Check type of uploaded file
| From: | Bob Hockney | Date: | Mon, 08 Dec 2003 00:04:49 +0000 |
| Subject: | Re: Check type of uploaded file | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-172135@lists.php.net to get a copy of this message | ||
Richard Davey wrote:
> BH> I want to test an uploaded file to see if it is a text file, but I don't want
> BH> to rely on the presence of an os command such as 'file.' Is there a
> BH> straightforward way to do this within PHP? Thanks in advance.
>
> Yes, check the $_FILES['userfile']['type'] after upload.
I tried this initially, but the problem is that it relies on the client's
interpretation of the file type. With the files I used for testing, Konqueror and
other reported the MIME type as text/plain, but Mozilla reported it as
application/octet-stream. What I am looking for is a way to test the file
depending only upon PHP. i.e., to be platform and client independent.
-Bob