Yii module/component to quickly add file uploader support to any model.

Webkadabra Media Uploader

Author: Sergii Gamaiunov hello@webkadabra.com


Get source from https://bitbucket.org/webkadabra/wkd-yii-mediauploader


1. Preparation

  1. Copy contents of this folder to /path/to/extensions/wkd/components/media-uploader folder

  2. Install MySql schema

See database.sql

  1. Make sure your Yii application has 'wkd' path alias pointed to /path/to/extensions/wkd/

2. Usage Example

  1. Add MediaUploader to Controller map in app config:

'controllerMap'=>array( 'mediaUploader'=>array( 'class'=>'wkd.components.media-uploader.MediaUploaderController', ), ),

  1. Add path alias for tmp uploads folder in config:

'params'=>array( ... 'envTempDir' => 'application.runtime', // uploader temp folder ),

  1. In your views, add uploader widget:

// Uploader, Must be called before RTEditor: $this->widget('wkd.components.media-uploader.MediaUploaderWidget', array( 'options' => array( 'uploadUrl' => app()->createUrl('mediaUploader/upload', array('modelName' => get_class($model), 'modelID' => $model->id)), 'browseUrl' => app()->createUrl('mediaUploader/index', array('modelName' => get_class($model), 'modelID' => $model->id)), ), 'boundModel' => $model, #'forceAssetsCache'=>true, ));

  1. To open up an uploader window, call Javascript helper function mediaUploaderWindow.open()

Total 3 comments

#17244 report it
rhomb at 2014/05/15 07:13am
just mentioning

@b3atb0x Didn't want to sound ungrateful or anything. Was just posting the comment, as I think it is important to know that it will use some customization to get it running.

Especially the dependency to yiibootstrap should be mentioned up top.

For sth provided to the community the code should not contain inconsistencies like the use of app() instead of Yii::app(), or the alias should be defined in the module itself

#17233 report it
b3atb0x at 2014/05/14 12:43pm
just a component

This one is used a lot in our internal project, and I hope later we will release better version. However, it's dependancy on YiiBootstrap is only in views, and you can create your own view. Please, keep in mind this is more of a "placeholder" release - hopefully, wehn we release all component that are reused a lot in our projects, communirt will be more pleased! Thanks!

#17232 report it
rhomb at 2014/05/14 12:35pm
  • dependend on yiistrap or yiibooster (not sure)
  • uses app() alias for Yii::app()
  • threw it away after seeing dependency on yiistrap, as I'm working in a bootstrap 3 system w/o either extension

Leave a comment

Please to leave your comment.

Create extension
No downloadable files yet
  • Yii Version:
  • License: Other Open Source License
  • Developed by: b3atb0x
  • Category: User Interface
  • Votes: +1 / -1
  • Downloaded: 0 times
  • Created on: Feb 4, 2014
  • Last updated: never