bmcclure/cakephp-media-plugin

CakePHP 媒体插件

安装数: 1,402

依赖者: 0

建议者: 0

安全: 0

星标: 60

关注者: 11

分支: 60

开放问题: 3

类型:cakephp-plugin

dev-cake-2.0 / 2.x-dev 2014-04-18 17:04 UTC

This package is auto-updated.

Last update: 2024-08-29 04:03:23 UTC


README

##数据库字段

    create table users (
    id char(36) not null,
    file varchar(255) default null,
    dirname varchar(255) default null,
    basename varchar(255) default null,
    checksum varchar(255) default null,
    created datetime default null,
    modified datetime default null,
    primary key(id)
    );

##安装

  1. 克隆到 /path/to/app/Plugin git clone https://bmcclure@github.com/bmcclure/CakePHP-Media-Plugin.git Media
  2. 作为子模块添加 git submodule add https://bmcclure@github.com/bmcclure/CakePHP-Media-Plugin.git Plugin/Media
  3. 加载插件。
    ``//Within your bootstrap.php``
    ``CakePlugin::load('Media', array('bootstrap'=>true));`
  1. 初始化媒体文件。 cake Media.Media init
---------------------------------------------------------------
Media Shell
---------------------------------------------------------------
Do you want to create missing media directories now?  
[n] > y``
/app/webroot/media/                               [OK  ]
/app/webroot/media/static/                        [OK  ]
/app/webroot/media/static/aud                     [OK  ]
/app/webroot/media/static/doc                     [OK  ]
/app/webroot/media/static/gen                     [OK  ]
/app/webroot/media/static/img                     [OK  ]
/app/webroot/media/static/vid                     [OK  ]
/app/webroot/media/transfer/                      [OK  ]
/app/webroot/media/transfer/aud                   [OK  ]
/app/webroot/media/transfer/doc                   [OK  ]
/app/webroot/media/transfer/gen                   [OK  ]
/app/webroot/media/transfer/img                   [OK  ]
/app/webroot/media/transfer/vid                   [OK  ]
/app/webroot/media/filter/                        [OK  ]

Your transfer directory is missing a htaccess file to block requests.
Do you want to create it now?  
[n] > n
  1. 设置媒体文件夹的权限
chmod -R 777 webroot/media/{transfer,filter}

##上传和查看图片

  1. 将模型设置为媒体传输用户
````
  1. 设置表单
``echo $this->Form->create('User', array('type'=>'file'));``
``echo $this->Form->input('file', array('type'=>'file'));``
``echo $this->Form->input('dirname', array('type'=>'hidden'));``
``echo $this->Form->input('basename', array('type'=>'hidden'));``
``echo $this->Form->input('checksum', array('type'=>'hidden'));``
``echo $this->Form->end(__('Submit'));``
  1. 要查看图片,将 Media 辅助器添加到控制器中并使用
``Media->embed(h($employee['User']['basename'])); ?>``
  1. 享受吧!