dala00/cakephp-simple-upload
Composer 安装命令:
composer require dala00/cakephp-simple-upload
包简介
Upload handle plugin for CakePHP
README 文档
README
Description
- Handle file post to save and upload automatically.
- UploadHelper can output URL and img tag on template.
- Methods for confirm page are available.
Installation
You can install this plugin into your CakePHP application using composer.
The recommended way to install composer packages is:
composer require dala00/cakephp-simple-upload
And load plugin on bootstrap.php.
Plugin::load('Dala00/Upload');
Usage
Load UploadBehavior with options.
class SomeTable extends Table { public function initialize(array $config) { $this->addBehavior('Dala00/Upload.Upload', [ 'fields' => [ 'photo' => [ 'path' => 'webroot{DS}files{DS}{model}{DS}{primaryKey}{DS}{field}{DS}' ], ], ]); } }
UploadHelper
You can output URL or img tag with UploadHelper.
// In Controller public $helpers = ['Dala00/Upload.Upload'];
(In Templates) <img src="<?= $this->Upload->url($entity, $fieldName) ?>"> or <?= $this->Upload->image($entity, $fieldName) ?> <?= $this->Upload->image($entity, $fieldName, $options) ?>
Using confirm page
If you want show confirm page before saving post, next method saves files as cache.
// Call in action when confirm page will be shown $this->SomeTable->uploadTmpFile($entity);
// Output hidden tag with UploadHelper on templates <?= $this->Upload->hidden($entity, $fieldName) ?>
Licence
统计信息
- 总下载量: 384
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 3
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-04-08