PHP Classes

PHP MySQL Image Display: Serve images added to a MySQL database table

Recommend this page to a friend!
  Info   View files Example   View files View files (6)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 273 All time: 7,657 This week: 209Up
Version License PHP version Categories
mysql-image 1.0.0GNU General Publi...5.6PHP 5, Databases, Graphics
Description 

Author

This class can serve images added to a MySQL database table.

It can execute SQL queries to store uploaded images files in a given MySQL table.

The class can also retrieve from the database table and serve image data for displaying as the current script output, retrieve the list of all images stored in the database, replace a given image already stored in the database table, and delete a given image from the database.

Recommendations

What is the best PHP upload files to database class?
Upload doc and pdf documents to a database using php

Picture of Richard Carson
  Performance   Level  
Name: Richard Carson <contact>
Classes: 4 packages by
Country: Canada Canada
Age: 31
All time rank: 200448 in Canada Canada
Week rank: 703 Up13 in Canada Canada Up

Details

SQLimg

Facilitates the storage and delivery of small images via MySQL. This method is far faster than traditional methods, and potentially less error-prone when uploading images often.

Method summary:

all($con=false) List all images in the database

$con: An optional database connection (optimization)
returns an associative array of keys and types

exists($key, $con=false) Determine weather or not a given image exists

$key: The image's unique key
$con: An optional database connection (optimization)
returns boolean

display($key) Display a stored image - CALL BEFORE HEADERS ARE SENT

$key: The image's unique key

upload($file, $key=null) Store an image through upload - uses the $_FILES superglobal

$file: The URL key to search for a file
$key: An image to replace (optional)
returns false if the image could not be uploaded, the new unique key otherwise

remove($key) Remove a stored image

$key: The image's unique key
returns false if the image did not exist, true otherwise

add($data, $type) Store a new image

$data: the image's binary
$type: the image's format
returns the image's unique key, or false on failure

replace($key, $data, $type) Replace an existing image

$key: The image's unique key
$data: the image's binary
$type: the image's format
returns false on failure, true otherwise
  Files folder image Files  
File Role Description
Accessible without login Plain text file config.php Conf. Configuration script
Accessible without login Plain text file example.php Example Example script
Accessible without login Plain text file install.sql Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file readme.txt Doc. Documentation
Plain text file sqlimg.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:273
This week:0
All time:7,657
This week:209Up