Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IE8 shows html source, not web-page 1

Status
Not open for further replies.

MichaelHooker

Programmer
Mar 17, 2006
70
GB
There must be something about IE8 I haven't cottoned on to yet.

The private admin part of my website has a page for updating the MySQL database and uploading image files relating to the new entries. It leads on to a separate page using simple css, some moderately complex php (by my standards) and simple html (no javascript) which deals with the uploaded image, makes a thumbnail and then reports back with a small table containing details of what was just uploaded, including the thumbnail, just to prove it worked (and confirm to me that I uploaded the right one!). It works fine in IE7, but IE8 just displays the php-generated source code. The php logic of the page still works OK, as the images and thumbnails all appear on the website as they should.

This is the only page I have ever come across which IE8 (or any browser for that matter) treats in this fashion. I have absolutely no idea where to start looking in the coding for what may be causing it. Or is it the result of an obscure setting in IE8?

Can anyone point me in the right direction please?

Thanks in advance.

Michael Hooker
 
Hi

Check the HTTP response headers, especially the [tt]Content-type[/tt]. Use a tool for that :
[ul]
[li]Browser:
[ul]
[li]FireFox:
[ul]
[li]Live HTTP Headers[/li]
[li]FireBug[/li]
[li]Web Developer[/li]
[/ul]
[/li]
[li]Lynx[/li]
[li]Links[/li]
[li]W3M[/li]
[li]Explorer:
[ul]
[li]ieHTTPHeaders[/li]
[li]IEWatch[/li]
[/ul]
[/li]
[/ul]
[/li]
[li]tool:
[ul]
[li][tt]netcat[/tt][/li]
[li]PuTTY[/li]
[li][tt]telnet[/tt][/li]
[li][tt]Wget[/tt][/li]
[li][tt]cURL[/tt][/li]
[/ul]
[/li]
[/ul]

Feherke.
 
Thanks. I have downloaded and installed iehttpheaders, though to be quite honest I do not understand what it is supposed to be telling me.

I cannot test again to see what happens until I have more images to upload, so I will have to come back to you later. I presume I need to send a copy of the data produced by iehttpheaders and ask what it means? I have also installed it on a PC that still uses IE7, should I be comparing the IE8 log against the IE7 log?

Thanks again

Michael Hooker

 
Hi

Michael said:
I have downloaded and installed iehttpheaders, though to be quite honest I do not understand what it is supposed to be telling me.
It will show the HTTP headers. The browsers are handling the received response according to what the headers are saying about it. HTML documents should be delivered with [tt]Content-type: text/html[/tt] header.

Of course, if you have no HTTP experience, would be better to post the whole HTTP header part of that erroneous response.

Feherke.
 
Hi - another 125 photos added today.

In WinXP/IE7, here is the iehttpheaders log from the point of entry to the relevant page (addfile.php) which receives the uploaded image, processes it, and if successful returns a table containing response codes and the thumbnail that the php has just created. The Vista/IE8 version follows after this. I have edited the URLs and cookies for privacy's sake.

POST /PHPTests/addfile.php HTTP/1.1
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-excel, application/msword, application/xaml+xml, application/vnd.ms-xpsdocument, application/x-ms-xbap, application/x-ms-application, application/x-shockwave-flash, */*
Referer: Accept-Language: en-gb
Content-Type: multipart/form-data; boundary=---------------------------7d91d41d2602d4
UA-CPU: x86
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; .NET CLR 1.0.3705; .NET CLR 1.1.4322; Media Center PC 4.0; .NET CLR 3.0.04506.30; .NET CLR 2.0.50727)
Host: Content-Length: 191843
Connection: Keep-Alive
Cache-Control: no-cache
Cookie: ABCD=123; EFGH=456

-----------------------------7d91d41d2602d4
Content-Disposition: form-data; name="upfile"; filename="F:\Documents\N741PA_lb.jpg"
Content-Type: image/pjpeg

ÿØÿà

HTTP/1.1 200 OK
Date: Mon, 18 May 2009 15:58:31 GMT
Server: Apache/1.3.41
X-Powered-By: PHP/5.2.6
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: image/jpeg

GET /TImg/N741PA_lb.jpg HTTP/1.1 <<< the thumbnail
Accept: */*
Referer: Accept-Language: en-gb
UA-CPU: x86
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; .NET CLR 1.0.3705; .NET CLR 1.1.4322; Media Center PC 4.0; .NET CLR 3.0.04506.30; .NET CLR 2.0.50727)
Host: Connection: Keep-Alive

HTTP/1.1 200 OK
Date: Mon, 18 May 2009 15:58:43 GMT
Server: Apache/1.3.41
Last-Modified: Mon, 18 May 2009 15:58:43 GMT
ETag: W/"198a3c4-123c-4a1185b3"
Content-Length: 4668
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: image/jpeg

Here is the Vista/IE8 version of the same thing. The problem is that the browser returns html source code to the screen and not the table and image. I don't understand what the reference to GET /go/rss/googlebuttonairportdelays.do HTTP/1.1 is or what comes after it, I guess the google button bar is doing its own thing there. Certainly nothing appears on the screen in response. But that little paragraph seems to actually replace what's probably a votal one in the IE7 version. Next time I have some photos to upload should I try switching the Google toolbar off first?

POST /PHPTests/addfile.php HTTP/1.1
Accept: image/gif, image/jpeg, image/pjpeg, application/x-ms-application, application/vnd.ms-xpsdocument, application/xaml+xml, application/x-ms-xbap, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, application/x-shockwave-flash, */*
Referer: Accept-Language: en-us
User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; GTB6; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.30729; .NET CLR 3.0.30618; OfficeLiveConnector.1.3; OfficeLivePatch.0.0)
Content-Type: multipart/form-data; boundary=---------------------------7d91de17340430
Accept-Encoding: gzip, deflate
Host: Content-Length: 197367
Connection: Keep-Alive
Cache-Control: no-cache
Cookie: ABCD=123; EFGH=456

-----------------------------7d91de17340430
Content-Disposition: form-data; name="upfile"; filename="CS-TNA_bt.jpg"
Content-Type: image/pjpeg

ÿØÿà

HTTP/1.1 200 OK
Date: Mon, 18 May 2009 20:24:37 GMT
Server: Apache/1.3.41
X-Powered-By: PHP/5.2.6
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: image/jpeg

GET /go/rss/googlebuttonairportdelays.do HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; GTB6; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.30729; .NET CLR 3.0.30618; OfficeLiveConnector.1.3; OfficeLivePatch.0.0)
Host: Connection: Keep-Alive
Cookie: style=default; __gads=ID=2618758b798e8fa7:T=1236123280:S=ALNI_MZxMkhIYfASuZUHs07I4ZkLB0x3RA; __qca=1235916219-20619948-35158744; __utma=104620247.1941498116.1236123280.1241210136.1241211106.3; __utmz=104620247.1241211339.3.3.utmcsr=google|utmccn=toolbar|utmcmd=cpc

HTTP/1.1 200 OK
Date: Mon, 18 May 2009 20:26:00 GMT
Server: Apache/2.0
X-Powered-By: Servlet 2.4; JBoss-4.0.4.CR2 (build: CVSTag=JBoss_4_0_4_CR2 date=200603311500)/Tomcat-5.5
Set-Cookie: JSESSIONID=342DE0E5CBFA9F49882FB6F9324FD0EA.web2:8009; Path=/
Content-Type: text/xml;charset=UTF-8
Vary: Accept-Encoding,User-Agent
Content-Encoding: gzip
Keep-Alive: timeout=15, max=100
Connection: Keep-Alive
Transfer-Encoding: chunked

I hope the answer is in there somewhere!

Thanks

Michael Hooker
 
feherke wrote:

Of course, if you have no HTTP experience, would be better to post the whole HTTP header part of that erroneous response.

I don't have any http experience. I did post the HTTP headers. It wasn't better.

Michael Hooker
 
Hi

Sorry, I had lot of work that time.

I took a look to the HTTP headers you posted, but I did not understood. But not I was unable to decide in predictable time that I am confused or you made some mistake. So I postponed the reply and you know the end : I forgot it.

You wrote this :
Michael said:
makes a thumbnail and then reports back with a small table containing details of what was just uploaded, including the thumbnail
This means that addfile.php
[ul]
[li]will save the uploaded image to /Img/N741PA_lb.jpg[/li]
[li]generate the thumbnail /TImg/N741PA_lb.jpg[/li]
[li]output a HTML document containing a [tt]table[/tt] like this :
Code:
[gray]<table>[/gray]
[gray]<tr><td>[/gray]File[gray]</td><td>[/gray]N741PA_lb.jpg[gray]</td></tr>[/gray]
[gray]<tr><td>[/gray]Type[gray]</td><td>[/gray]JPEG[gray]</td></tr>[/gray]
[gray]<tr><td>[/gray]Size[gray]</td><td>[/gray]19 Kb[gray]</td></tr>[/gray]
[gray]<tr><td>[/gray]Thumb[gray]</td><td>[/gray]<img src="/TImg/N741PA_lb.jpg">[gray]</td></tr>[/gray]
[gray]</table>[/gray]
[/li]
[/ul]
?

In this case the content type returned by addfile.php is wrong. Search for a [tt]header()[/tt] call in the source code and change it to this :
Code:
header('Content-type: text/html');
If there is no such function call, you will have to add it. It must be placed before the response body, so before the HTML's [tt]DOCTYPE[/tt] tag, or whatever is the first tag.

If that is not how addfile.php works, then I was right : I am confuse.

Feherke.
 
Hi

I'm back again. I had given up waiting, and simply used the IE7 laptop to do the job instead. And I didn't get an a-mail notification of your answer.

Strangely when I upgraded the laptop to IE8 it carried on working fine, until today when suddenly I had the big problem again. I have disabled every toolbar and add-on (except ieHTTPHeaders) and it makes no difference. I even installed Firefox - this reacts differently, it does not display the source html of the web-page, it simply repeats the url. But it certainly does not display the web-page.

Addfile.php is a little more complicated than your summary, but you have the basic idea. It tests the uploaded image for file-type and acceptable file-size; and it checks the desired file-name to make sure this does not already exist. If all is OK, it saves the jpg at the original size, makes a smaller version and saves that, then makes a thumbnail and saves that. It then produces a report of what it has done in the form of the table you mention, which also displays the thumbnail which has just been created if everything worked. And a vital "back" button that gets me back to the page where I start adding a new database entry for the next image to be uploaded.

Now, the application contains this line, just before the new images are created:
Code:
header('Content-type: image/jpeg');
As I understand it, this is vital for the image creation routines to work, so cannot be changed.

Is the general idea that any php code resulting in screen html output should be preceded by a line like
Code:
header('Content-type: text/html');
and that this is the default unless you change it? So it should be possible to insert this line after the imaging process is finished to switch back to text/html?

I tried this and to my surprise it worked, everything is back to normal.

Presumably IE7 was clever enough to work out how to display my table without being told, but IE8 requires the instruction - not initially, but after a short period os use. [ponder]


Many thanks

Michael Hooker
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top