fknussel/image-uploader
Composer 安装命令:
composer require fknussel/image-uploader
包简介
A simple and elegant PHP library for uploading and serving images
README 文档
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.
统计信息
- 总下载量: 19
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-05-03