fknussel / image-uploader
A simple and elegant PHP library for uploading and serving images
Installs: 19
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 17
pkg:composer/fknussel/image-uploader
Requires
- php: >=5.5.0
This package is not auto-updated.
Last update: 2025-12-13 00:07:26 UTC
README
A simple yet elegant PHP library for uploading and serving images. The aim of this project is to act as an interface to image uploading and serving on a media server.
Prerequisites
- Successfully tested on PHP >= 5.5
- GD is required (
sudo apt-get install php5-gdwill do)
Installation using Composer
Add the following dependency to your composer.json file:
{
"require": {
"fknussel/image-uploader": "dev-master"
}
}
Fetch the dependecy by running:
php composer.phar install
Finally, import image-uploader into your script:
require("vendor/autoload.php");
Usage
Serving images
try { $imageUploader = new ImageUploader(UPLOAD_DIR, MD5_HASH_SALT); $res = $imageUploader->serve($_GET["identifier"]); var_dump($res); } catch (Exception $e) { var_dump($e); }
Uploading images
try { $imageUploader = new ImageUploader(); $imageUploader->setPath(UPLOAD_DIR); $imageUploader->setSalt(MD5_HASH_SALT); $imageUploader->setMaxFileSize(MAX_FILE_SIZE); $uid = time() . rand(); $success = $imageUploader->upload($_FILES[INPUT_FIELD_NAME], $uid); echo json_encode(array("success" => $success)); } catch (Exception $e) { die($e); }
License
image-uploader is MIT licensed.
This project is a somewhat modified version of Dhaval Kapil's image-uploader.