---
id: 138
title: ByteHoard x-sendfile patch
date: 2009-02-06T03:43:35+00:00
author: hky
layout: post
guid: http://lostfocus.org/blog/?p=138
permalink: /bytehoard-x-sendfile-patch/
syntaxhighlighter_encoded:
 - 1
dsq_thread_id:
 - 620037883
categories:
 - General
tags:
 - Lab
---
> ByteHoard is a PHP-based web storage system, providing a web interface for users to upload, download, share and edit files, all via their browser. Includes thumbnails for images, multiple database support, skinning support, directory support and much more

But it lacks of x-sendfile support. When you use ByteHoard to serve large file and many concurrent user, i’m pretty sure your server will be out of resource immediately. So, why don’t serve those files direct to webserver, It will safe your resource.

This is a patch for ByteHoard 2.1 Epsilon.

Around line 104 on your filelink.php file, change the line :

<pre class="brush: php; title: ; notranslate" title="">$fileobj-&gt;readfile()</pre>

with :

for Lighttpd 1.4

<pre class="brush: php; title: ; notranslate" title="">header("X-LIGHTTPD-send-file: /path/to/upload-data" . $filepath);</pre>

for Lighttpd 1.5 and Apache2 with mod_xsendfile

<pre class="brush: php; title: ; notranslate" title="">header("X-Sendfile: /path/to/upload-data" . $filepath);</pre>

for nginx

<pre class="brush: php; title: ; notranslate" title="">header("X-Accel-Redirect: /path/to/upload-data" . $filepath);</pre>