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_fff
with these columns- 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_I
orPrimary
just clickGo
on the pop-up- click
Save
- click
What Actually Happens?
Upload
- The image is uploaded
Web::instance()->receive
deals with getting things on the serverImageServer::receiveCallback
can be configured for dealing with when things go wrong
- the
store
function actually saves the metadata to the database.- images don’t get stored in a database as they are too large.
- you can configure
store
to 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
datalist
variable ofviewimages.html
viewimages.html
then callsFFF-ImageServer/image/@id
andFFF-ImageServer/thumb/@id
urlsFFF-ImageServer/thumb/@id
forwards raw data to<img>
as files are above web root.- Both
FFF-ImageServer/thumb/@id
FFF-ImageServer/image/@id
can be used in conjunction with<img>
.