xupload jquery file upload extension for yii

  1. Demo
  2. Setup instructions
  3. Additional Documentation
  4. Resources
  5. Changelog
  6. Colaborators
  7. License


jQuery file upload extension for Yii, allows your users to easily upload files to your server:

Setup instructions

Using composer

Add to your composer.json

    "config": {
        "vendor-dir": "protected/extensions/vendor"
    // custom repository is not needed, you can find it in packagist.org
    "repositories": [
        ... //Other repositories
    "require": {
        ... //Other packages
        "asgaroth/xupload": "v0.5.0"


Download the files and extract them to you project desired folder

  1. Add an application alias in you application configuration that points to the extracted folder
// protected/config/main.php
'aliases' => array(
    //If you used composer your path should be
	'xupload' => 'ext.vendor.asgaroth.xupload'
	//If you manually installed it
	'xupload' => 'ext.xupload'
  1. Create a model, declare an attribute to store the uploaded file data, and declare the attribute to be validated by the 'file' validator. Or use XUploadForm
  2. Create a controller to handle form based file uploads. Or use XUploadAction
  3. Add the Widget to you view
$this->widget('xupload.XUpload', array(
					'url' => Yii::app()->createUrl("site/upload"),
                    'model' => $model,
                    'attribute' => 'file',
                    'multiple' => true,

Info: Ensure that the apache server has write permissions in the folder you are uploading the files, XUpload will try to create the upload folder if it doesn't exist already.

Using XUploadAction and XUploadForm:
  • XUploadAcion adds basic upload functionality to any controller.
  • XUploadForm its a simple form model to store uploaded file data
  1. Override CController::actions() and register an action of class XUploadAction we (will use 'upload' for the examples), and configure its properties:
class SiteController extends CController
    public function actions()
        return array(
                'path' =>Yii::app() -> getBasePath() . "/../uploads",
                'publicPath' => Yii::app() -> getBaseUrl() . "/uploads",
  1. Create an initial action that will render the form using the XUploadModel:
public function actionIndex() {
		$model = new XUploadForm;
		$this -> render('index', array('model' => $model, ));

Additional Documentation

Here is a wiki describing a more complex workflow using this widget.

And a wiki explaining how to send additional data with your file

Note: See the attached project for more examples



v0.5.0 Sat Nov 10 19:17:16 COT 2012
  • Added $formClass to XUploadAction, to allow overwriting the default form class
  • Improved location of thumbnail url handling
  • Improved security
  • Setup public variables to make using other form models / Active Record models easier.
  • JavaScript-part of extension now properly depends on XUpload::$multiple parameter
  • Added I18N support, added russian translation
  • Fixed incorrect behavior when XUploadAction::$subfolderVar was false
  • No script files are now loading from github.com/blueimp, all of them are locally available now
  • Added XUpload::$showForm param - this allows easily avoid rendering tag in widget view
v0.4.0 Mon Jul 2 16:25:53 COT 2012
  • Added image preview assets
  • Added image processing assets
  • Added the ability to specify upload, download, and form views
v0.3a Sun Mon Apr 2 21:43:38 COT 2012
  • Fixed missing dependencies
v0.3 Sun Apr 1 18:35:23 COT 2012
  • Updated to the new jquery plugin version
v0.2 Sun May 8 19:28:43 COT 2011
  • Added Multiple file uploading functionality
  • Integrated XUploadAction with a few changes (thanks to tydeas_dr)
  • Moved XUploadForm to the extension folder
v0.1 Mon Mar 21 14:51:13 COT 2011
  • First release



Released under the MIT license.

97 14
36 791 downloads
Yii Version: 1.1
License: MIT
Category: User Interface
Developed by: Asgaroth
Created on: Mar 27, 2011
Last updated: 10 years ago


show all

Related Extensions