Pictures partially displayed, tinyMCE problem, lightbox2 problem because of sendfile
July 25, 08 by the programmerI had this problem a long time, I found a post I wrote from 2007-10-27.
The symptoms are
- Pictures displayed from the web server are not complete, only the top part of the picture is displayed, and the rest of the picture is black. This usually happens if the picture is very big (high resolution)
- Weird javascript problems. Problems occur only if the Javascript is served by the apache web server. The problem can gennerally occur with every static file.
This is the configuration I have:
Apache 2.0.54 on Windows XP Professional SP2
PHP 4.4.4
MySQL 4.1.12
I noticed the problem once when I was making a picture upload. I noticed that when I try to view the uploaded picture I could see only a part of the image, only the top part and never the full image.
This was pretty weird for me at the time, so I tried to see if the same is going to happen on the production server, because that was on my local server. Everything was ok on the production server so I did not bothered to fix the problem because it did not make any difference for me.
After a while I tried to install TinyMCE, a free HTML WYSIWYG editor, version 2.1.2. I run the examples from the desktop folder before uploading them to the local web server, and they were working great. After I saw that the examples were working I wanted to put them in my project and I copied all the files to the htdocs folder on the apache web server.
After I uploaded the files I tried to run the same example scripts but I noticed that they are not working, and that there was an error in firebug.
This is what the error was:
skins.html (line 10)
Displaying pictures from http
Dispaying half images
I had a filling that the poblem must be in the php, apache configuration. Maybe something with the encodings, or the file size limitation or something similar. But it had to be with some confuration. So I decided that I have to solve this problem. I started to search the net for any similar cases and I found a post that is not very related to this problem but I decided to try.
I found this post: CSS and Javascript files not showing up when running Apache under Ubuntu on a flash drive? Read on. (Many thanks to the writer for writing the solution)
This guy had some similar problem, not displaying images, javascript files problem, so I thought I would give it a try.
As I found out later from the post apache by default uses a system command from the operating system called sendfile.
This command tries to deliver the static files to the browser, but because I am using Windows XP and it is “Windows operating system”, there must be some problem with it.
So I found out that Apache by default checks if the operating system supports sendfile syscall, and if it does then it uses it from the operating system, and if not it uses his own implementation of the functionality. Aslo I found out that there is a configuration property called EnableSendfile in the http.conf file, the Apache configuration file, which by default is on, which means use operating system function.
I set this configuration property to off, restarted Apache and BINGOOOOOOOOOOOOOO.
Everythig worked.
The pictures were showing up, both versions of the tinyMCE editor were working and the lightbox2 script was working. Finally after more that 9 months the problem is resolved
So if you have similar problems open httpd.conf, find “EnableSendfile” and set it to off like this:
EnableSendfile off
Dont forget to restart Apache after changing the configuration file
The symptoms as I mentioned before are
- Pictures displayed from the web server are not complete, only the top part of the picture is displayed, and the rest of the picture is black. This usually happens if the picture is very big (high resolution)
- Weird javascript problems. Problems occur only if the JavaScript is served by the apache web server.
More about EnableSendfile can be found here:
http://wiki.apache.org/httpd/SendfileNotImplemented
http://httpd.apache.org/docs/2.0/mod/core.html#enablesendfile
I hope this post will be useful to somebody with similar problems
Thank you
