Distributing Large Files (Several GB) to Users on XenForo

Distributing Large Files (Several GB) to Users on XenForo

Distributing Large Files (Several GB) to Users on XenForo.webp


Allowing users to upload or download very large files (several gigabytes) directly through your XenForo site is extremely challenging. It can affect server performance, consume significant disk space, and often run into upload limits imposed by services like Cloudflare Free Plan, which only allows file uploads up to 100 MB.

Because of these limitations, most administrators prefer to host large files externally, such as on Google Drive, OneDrive, or similar cloud storage services.

However, if your server has an additional storage drive (for example, an HDD alongside your SSD), you can mount that drive to a specific directory and use it to store and distribute large files efficiently.
A detailed guide for mounting an external drive on Linux can be found here:
https://xenvn.com/threads/how-to-mo...as-storage-for-xenforo-uploads-on-linux.5900/

XenVn provides ready-to-use tools to help you configure this setup easily.
For uploading large files directly to your server, you can use free third-party software such as FileZilla, WinSCP, or similar FTP clients.

Distribute Large Files Separately
To simplify large file distribution, XenVn provides a download.php script.
  1. Download the download.php file. The download link will be found at: XenVn Setting -> Storage -> External Storage URL / Path
  2. Set the FOLDER constant to the directory path where your large files are stored.
  3. (Optional) If you set CONNECTION_KEY_CODE, you must enable the Add Redirect Page feature.
  4. Upload the script to the root directory of your XenForo installation.
1761316022668.webp

Attachment Download Acceleration
This feature enables attachments to be delivered in chunks through HTTP Range requests, allowing users to resume interrupted downloads and fetch only the parts they need from large files without starting over. It improves compatibility with download managers and significantly enhances the user experience, especially for communities sharing large resources.

This script supports three delivery methods: X-Sendfile (Apache), X-Accel-Redirect (Nginx), and PHP-based Chunked Streaming. To use X-Sendfile / X-Accel-Redirect, you need to setup: ACCELERATION and NGINX_ALIAS and require the server to support them
With X-Sendfile (Apache), X-Accel-Redirect (Nginx) your server will easily deliver large files of several GB to users without consuming too much performance.
See more:
https://xenvn.com/threads/enable-external-storage-connection-for-xenforo-2-attachments.5627/

Your download URL will look like this:
domain.com/download.php?path=xxx
xxx can be:
  • The path to the specific file you want to download, or
  • The directory containing the file - in which case the script will automatically detect and serve the newest file inside that folder.
Note: The path specified in xxx should not include the FOLDER directory you configured.

If you set:
define('FOLDER', 'external/share');
and inside /external/share/ you create a subfolder named fileiso, containing a file called file.iso,
you can generate a download link in one of two ways:
domain.com/download.php?path=fileiso/file.iso
or
domain.com/download.php?path=fileiso
In the second case, the script will automatically find the latest file in that directory and start the download.

When you enable Add Redirect Page feature. The url will be encoded in the form: domain.com/download.php?data=*** and will go through the redirect page. This will help to inherit the advanced features of Add Redirect Page.

Here is an example link:
https://xenvn.com/redirect/?to=IAKPXGrDWoK/7DaIuCDg18a6DEXAXqrB7zmuHc6GNyZQzkg/IbShmrYCBMISSS0ItNZC9uvX65pF+kQPyhHgfw==

This method keeps your main web hosting clean, reduces the pressure on your server, and provides a flexible, cost-effective solution for delivering very large files directly from your server.
 
Last edited:
Back
Top Bottom