I've had 2 thoughts on this one. They're fairly uneducated an just
meandering speculation, but it's my tuppence-worth so...

My initial thought was this: I believe the Content-Type: MIME header is
added by your browser. HTTP standards say that anything sending a file
over HTTP is supposed to tell the recipient what type of file it's
sending. It does this by adding the Content-Type: header at the start of
the stream. Normally, PHP will read this header and put it in the
$_FILES['userfile']['type'] variable. Perhaps your Linux browser adds
the header in such a way that PHP cannot extract it properly, and simply
thinks it's part of the file? You could try checking the
$_FILES['userfile']['type'] variable to see if it contains the correct
MIME type.

It then dawned on me that I know either Apache or PHP (can't remember
which, possibly both, but most likely Apache) can so some clever stuff
where it fills in missing MIME type headers by analysing the file being
transferred. It's possible that your Linux browser is not sending a
Content-Type: header and so Apache tries to fill one in and it's APACHE
that is adding the iffy header that PHP doesn't recognise.
Alternatively, it's possible that your browser IS adding the header, but
Apache doesn't recognise it, so adds another one. PHP happily extracts
the first one, but doesn't spot the second one so it creeps through.

Of course, all that could be wrong as I'm not an expert on file uploads,
but it might be a place to start looking.

Regards,
Rich


-----Original Message-----
From: David Freeman [mailto:dfreeman@;outbackqld.net.au] 
Sent: 30 October 2002 9:23 pm
To: [EMAIL PROTECTED]
Subject: RE: [PHP] Re: File Upload Problem



G'day David

 > > My problem is that files uploaded through a form are 
 > > increasing in size.

 > Doesn't that look like the EOL characters are being 
 > translated after the fashion of ftp ascii transfers?

 > Maybe have a look at the two versions in a 
 > hex viewer and see if that is the case? 

Yes, I'd considered that.  That was what I'd gone looking for in config
files etc.  I'd hoped to find a switch for ftp transfer mode.  Didn't
find one though.

However, partly because of your email and partly because I noted that
the file size increase was the same every time (27 bytes) I decided to
load it into a hex editor.

What I found was that at the top of the file, the following had been
added:

-----8<-----
Content-Type: image/gif

-----8<-----

I also found that if I remove these two lines the image will display
perfectly.

So, my next question is, why does my linux box add this to an uploaded
image and my windows box not do so?  Can someone make a suggestion on
where I should be looking?  Is the addition of this information a server
(Apache) thing?  Or is it a php thing?

CYA, Dave





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to