FFF-ImageServer Example
This is a very basic example of how to implement an image server the Fat Free Framework.
Structure
The structure is identical to the FFF-SimpleExample. If you have not got that example working yet, then do that first.
autoload/ImageServer.php
The main addition to the FFF-SimpleExample is the ImageServer class in autoload/ImageServer.php.
Setup
There are a couple of steps to take in order to setup this example
- go to your edinburgh.domains dashboard
- go to phpMyAdmin
- Select your database
Username_DatabaseName - click
New
- add a new table named
picdata_fffwith these columns- You will need to add an additional column

- You will need to add an additional column
| Name | Type | Length | Index | A_I |
|---|---|---|---|---|
| id | BIGINT | - | Primary | x |
| title | VARCHAR | 200 | - | - |
| filepath | VARCHAR | 200 | - | - |
| type | VARCHAR | 20 | - | - |
| thumbnail | VARCHAR | 200 | - | - |
- you can leave other unmentioned attributes blank.
- when you check
A_IorPrimaryjust clickGoon the pop-up
- click
Save
- click
What Actually Happens?
Upload
- The image is uploaded
Web::instance()->receivedeals with getting things on the serverImageServer::receiveCallbackcan be configured for dealing with when things go wrong
- the
storefunction actually saves the metadata to the database.- images don’t get stored in a database as they are too large.
- you can configure
storeto match your own requirements
View Image
The chain of events for viewing an image in via FFF-ImageServer/viewimages/ url is:
- viewimages calls ImageServer and gets all data
- this is passed to the
datalistvariable ofviewimages.html viewimages.htmlthen callsFFF-ImageServer/image/@idandFFF-ImageServer/thumb/@idurlsFFF-ImageServer/thumb/@idforwards raw data to<img>as files are above web root.- Both
FFF-ImageServer/thumb/@idFFF-ImageServer/image/@idcan be used in conjunction with<img>.