bmcclure / cakephp-media-plugin
CakePHP Media Plugin
Installs: 1 402
Dependents: 0
Suggesters: 0
Security: 0
Stars: 60
Watchers: 11
Forks: 60
Open Issues: 3
Type:cakephp-plugin
Requires
- php: >=5.2.8
- composer/installers: *
This package is auto-updated.
Last update: 2024-10-29 04:18:41 UTC
README
##Database Fields
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) );
##Installation
- Clone into /path/to/app/Plugin
git clone https://bmcclure@github.com/bmcclure/CakePHP-Media-Plugin.git Media
- Add as a submodule
git submodule add https://bmcclure@github.com/bmcclure/CakePHP-Media-Plugin.git Plugin/Media
- Load the plugin.
``//Within your bootstrap.php`` ``CakePlugin::load('Media', array('bootstrap'=>true));`
- Initialize Media files.
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
- Set the permissions for the Media folder:
chmod -R 777 webroot/media/{transfer,filter}
##Upload and View Image
- Set the model as media transfer user
````
- Set the form:
``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'));``
- To view image, add the Media helper to your controller and use:
``Media->embed(h($employee['User']['basename'])); ?>``
- ENJOY!