Pictures partially displayed, tinyMCE problem, lightbox2 problem because of sendfile

July 25, 08 by the programmer

I had this problem a long time, I found a post I wrote from 2007-10-27.

The symptoms are

  1. 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)
  2. 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:

tinyMCE is not defined
tinyMCE.init({

example_advanced…. (line 8 )

missing : after case label
function TinyMCE_Engine(){var ua;this.majorVersion=”2″;this.minorVersion=”1.2″;t…

At that time I made a post to the tinyMCE support forum. This is the post. Nobody new why this error was appearing because nobody responded to my post.

So I tried to find a solution of the problem on the net, but none was available, at least I could not find it.
I also tried to upload the scritpts to my production server and supprisingly everything worked great there, so the scripts were ok, and I tried to be suspicious of my PHP, Apache confuguration. I thought that this might be some security issue or something similar.

I could not fix the problem so I decided not to use tinyMCE and I worked without a HTML WYSIWYG editor.


2 Days ago I a friend asked me to make him a web page with picture gallery I and I decided to use the lightbox2 javascript picture gallery (version v2.04 Released 3/09/08). It is very nice. It looks great. I downloaded the javascript files on my desktop.
I run the example files from my desktop and they were working great.
Again I copied the same files in the htdocs folder and after I run the examples I got an error in the firebug console.
This is what the error was:

syntax error
if (parent == do

prototype.js (line 4417)

uncaught exception: script.aculo.us requires the Prototype JavaScript framework >= 1.6.0

Object.extend is not a function
}, window.LightboxOptions || {});


lightbox.js (line 63)



I remembered that I had problems with tinyMCE, with the pictures display and now with lightbox2 and I somehow new that all those problems must be related.
I aslo noticed that the problem happens only i the files are static, like .js files of .jpg files, and if the files are big. Both the tinyMCE and lightbox have a lot of lines of javascript code.


At that moment I went to the tinyMCE Web site and downloaded the latest version (v 3_1_0_1_2). I wanted to see if the same problem will appear with the new version again. It did. I After I run the example files from the htdocs folder I got a javascript error in the firebug console.
This was the error:

missing ) in parenthetical
var tinymce={majorVersion:’3′,minorVersion:’1.0.1′,releaseDate:’2008-06-18′,_ini…

tiny_mce.js (line 1)

tinyMCE is not defined
tinyMCE.init({

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

  1. 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)
  2. 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



This entry no have comments... but you can be first.

Leave a Reply