Uploads
The fast road in parallel pieces through chunk.php, Direct servers and S3 presigned parts, remote URLs, folder upload, the home-page trial upload and the limits a package sets.
Uploading is what a file host does all day, so BoxPuff gives it its own road. The browser asks for a ticket, sends the file in parallel pieces straight to where it will live, and asks to finish; the usual PHP upload limits do not apply. This chapter explains the roads, the uploader members see, and the rules a package puts on them.
The fast road: chunk.php
- The uploader posts
upload_beginwith the file's name and size. The site checks the package's rules (below), picks a file server, writes a ticket intouploads/tmp/and answers with the piece size, how many pieces may fly at once, and where to send them. - The browser cuts the file into pieces of Upload piece size (MB) (default 32, never over 90 because Cloudflare refuses bodies over 100 MB) and sends each as a
PUTtochunk.php?key=...&t=...&o=<offset>.chunk.phpstarts nothing of the site - no database, no session, no plugins - it checks the ticket's secret and writes the bytes at their offset. That is why several big pieces can be on their way at once and why a slow piece never blocks the others.GET chunk.php?key=...&t=...answers how much has arrived, so a dropped connection resumes where it stopped. upload_finishchecks the size, hashes the file (MD5), looks for a duplicate, moves it into storage and makes thebp_filesrow. Thumbnails and conversions start from thebp_file_uploadedhook.
Depending on the server picked, the pieces go to one of three places (the uploader shows Uploading to ...):
- this site -
chunk.phphere, then the file is moved to the local server, or pushed to an FTP/SFTP server or a bucket; - a Direct file server (
where = node) - the file server's ownchunk.phptakes the pieces and itsnode.phpfinishes the upload, so the main site never touches the bytes; - an S3 bucket with Direct Uploads on (
where = s3) - the site starts a multipart upload and hands the browser a presigned URL for every part (upload_part_url); pieces are at least 5 MB and go straight to the bucket, which must carry the CORS rule shown on the server form.
Parallel pieces: Site Settings → File Manager → Concurrent uploads and Concurrent upload limit (1 to 8), capped by the package's Concurrent Uploads.
The slow road
A server that refuses PUT (some proxies and old hosts) gets the pieces as ordinary multipart form fields of Form upload piece size (MB) (default 8), kept within upload_max_filesize. The uploader falls back by itself when a PUT fails; the result is the same file.
The uploader
Upload in the file manager (or /upload, which sends a member to /account?upload=1) opens a dialog with tabs:
- File upload - Drag, drop or paste files here (Ctrl+V pastes a screenshot), Choose files, Upload folder (keeps the folder structure: sub-folders are created automatically). Each row shows Waiting, Uploading with a progress bar, Done or Failed with Retry.
- Remote URL upload - Paste one URL per line and Fetch. HTTP, HTTPS and FTP addresses; private and local addresses are refused. With Remote url download in background off the files are fetched at once while the member watches; on, the cron job Remote URL downloads fetches them (three per run) and e-mails remote upload done. Admin → Files → Remote Uploads lists them all. The package decides with Enable Url Downloading and Max Remote Urls.
- Plugin tabs: FTP Upload and Torrent when those premium plugins are on.
Uploads are counted per day per account (or per IP for visitors). Hide the uploader when done closes the dialog by itself.
The home-page trial upload
The home page carries an upload box. A signed-in member uploads into the root of My Files. A visitor may upload too when Site Settings → File Uploads → Login required to upload is off and a package of type Non User (trial accounts) exists: a trial account is made and signed in on the spot (see The file manager), with that package's limits - the seeded Temp User allows 500 MB per file and 2 GB in all, keeps files 30 days after the last download and deletes the account 90 days after its last upload. Hide the box by setting home_show_upload to 0 (it has no form of its own; use the Database Browser's settings table), or simply require a login.
The rules a package sets
Checked on every road, including the API (Account packages):
| Package field | Effect |
|---|---|
| Users Can Upload | Off: Your account type is not allowed to upload. |
| Max Upload Size | Per file; the message offers an upgrade when the package shows upgrade prompts. |
| Storage Allowance | Total bytes; an admin can override it per user (Filesize Storage Limit). |
| Accepted / Blocked Upload File Types | Semicolon lists, e.g. .jpg;.png. |
| Max Uploads Per Day, Concurrent Uploads | Spam protection and load. |
| Enable Url Downloading, Max Remote Urls | The remote tab. |
Site-wide rules (Site Settings → File Uploads)
- Blocked extensions everywhere -
.php;.phtml;.phar;.cgi;.shby default, never allowed whatever the package says; Blocked filename keywords. - Block all uploads - for maintenance (admins excepted).
- Reuse identical files - the same bytes uploaded twice by one member are stored once (MD5). File hashing max filesize (GB) skips the hash above a size on slow hosts.
- Storage filename structure - Secure Hashed (xx/hash), the YetiShare layout, or User Id/Original Filename.
- Generate upload url type - how short links look: Shortest (counting up), Medium Hash (8) or Long Hash (16); File url shows the filename adds
/photo.jpgafter the short code. - File server selection method, Default file server, Server upload pooling - which server takes the file: File servers.
A blocked MD5 list (bp_blocked_hashes, filled by Bulk Remove on Abuse Reports) refuses known bad files whatever their name.
Where the bytes go
Each stored copy is an artifact (bp_file_artifacts) pointing at a server and a key such as 9c/9cfc7a.... Deletes, moves and copies between servers are queued and run by the cron job Process file queue; Admin → Files → Action Queue shows them. Pieces and tickets that never finished are swept from uploads/tmp/ after 36 hours by Purge deleted files.
Tips
- Behind Cloudflare keep the piece size at 32 MB or less and let the fast road do the work; a 20 GB upload then needs no change to PHP at all.
- On a tiny shared server set Concurrent upload limit to 2.
- Visitors should normally be allowed to upload: a trial account that turns into a registration is the classic file-host funnel. Watch Delete Account After Days on the trial package so abandoned trials do not pile up.
- Want members to bring in whole archives by FTP? That is the FTP Upload plugin; files already on the server are brought in with File Import.