RE: [PHP] Upload file on IE8
| From: | Ashley Sheridan | Date: | Tue, 26 Jan 2010 00:25:34 +0000 |
| Subject: | RE: [PHP] Upload file on IE8 | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-301432@lists.php.net to get a copy of this message | ||
On Mon, 2010-01-25 at 19:21 -0500, Ernie Kemp wrote:
>
>
>
>
>
>
>
> From: Ashley Sheridan [mailto:ash@ashleysheridan.co.uk]
> Sent: January-25-10 5:53 PM
> To: Ernie Kemp
> Cc: 'PHP General List'
> Subject: Re: [PHP] Upload file on IE8
>
>
>
> On Mon, 2010-01-25 at 17:41 -0500, Ernie Kemp wrote:
>
>
>
>
>
> Good Day,
>
>
>
> I’m having an issue with IE8, when I go to load a file the program is not
> filling the $_FILES['user_file']['type'] .
>
>
> When I display “echo
> "Start".$_FILES['pix']['type']."End";” in IE8 I get
> “StartEnd” with nothing in between. I expected “image/pjpeg".
>
> On FireFox I get “image/jpeg".
>
> Any suggestions?
> Thanks,
> ..../Ernie
>
>
>
>
> What do the other $_FILES fields say? Are they populated correctly?
>
> I wouldn't rely on anything sent from the browser. IE is known to send the mime type that
> matches the extension, not the contents of the file, and for .jpg images it sends a different mime
> to every other browser anyway, so it's pretty unreliable.
>
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
> With IE8,
>
> Using $_FILES the array results for ‘name’ has the name of the file but ‘type’,
> ‘tmp_name’ and ‘size’ are blanks.
>
> I tried enabling the “file path location” in IE8 option but the results are the same
> for $_FILES.
>
>
>
>
> Firefox works displays all the values in the $_FILES array.
>
> There must be a better way. Suggestions?
>
> Thanks,
>
> ..../Ernie
>
Don't use the value. There are a few different ways in PHP to get the
mime type of a file, which it does based on the contents of the file and
not its extension. This prevents someone from uploading an executable
virus for example by just changing the last three letters of the
filename.
Have a look at fileinfo() for this sort of thing.
Thanks,
Ash
http://www.ashleysheridan.co.uk