got a website where users view or download docs and pics they uploaded earlier.

let me show you what is working before I present the problem.
user clicks a link to their doc or image and browser opens it in new window.
browser url bar shows something like:
ALL IS WELL, this is working fine.

HOWEVER, I want to add a bit of security to keep users out of other people's folders.
ie, can't have them changing url to something like:

SO, using .htaccess I intercept all requests to /data/ and check authorization. once they get the green light, I open the file and pass it to the browser:

// Open the file for reading
$fp = fopen($_SERVER['DOCUMENT_ROOT'].$_SERVER['REQUEST_URI'], 'r');
// Set mime type to header
header('Content-type: '.mime_content_type($_SERVER['DOCUMENT_ROOT'].$_SERVER['REQUEST_URI']));
// Send the contents of the file the browser

HERE IS THE PROBLEM: headers getting screwed up. files do not open properly. not working in IE, FF, or CHROME. both before and after my security mod, identical REQUEST HEADERS are being sent:

Request Headers
User-Agent Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv: Gecko/20100722 AskTbHIP/ Firefox/3.6.8 (.NET CLR 3.5.30729)
Accept text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language en-us,en;q=0.5
Accept-Encoding gzip,deflate
Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive 115
Connection keep-alive
Cookie PHPSESSID=90bae8f5ad8ca690beaf8e389b2cc3fb

BUT I'M GETTING DIFFERENT RESPONSE HEADERS BACK. here is the good response - before the mod:

Response Headers
Date Tue, 03 Jul 2012 02:14:02 GMT
Server Apache
Last-Modified Tue, 03 Jul 2012 02:01:07 GMT
Accept-Ranges bytes
Content-Length 169175
Keep-Alive timeout=5, max=75
Connection Keep-Alive
Content-Type image/jpeg

AND here is the bad response - after the mod:

Response Headers
Date Tue, 03 Jul 2012 02:15:36 GMT
Server Apache
Expires Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma no-cache
Keep-Alive timeout=5, max=75
Connection Keep-Alive
Transfer-Encoding chunked
Content-Type image/jpeg

SO PLEASE, what do you make of this? looks like the headers are corrupted or lost by the PASSTHRU??