A simple action for XUpload extension

You are viewing revision #1 of this wiki article.
This is the latest version of this article.

All the basic functionality for an action used by the xupload extension. Check resources for the source code of this action


A file uploader is commonly a web application must have. There are pretty enough extensions in the yii project to achieve (other use flash, other are jquery...). I was suggested to use the xupload. After checking the project code, i noticed the action code that handles the request from the user.

"Do not repeat yourself"

Sticking with this motto, and due to the fact I did not want every controller that needs something to be uploaded to have that code plain in it, I created this CAction class. 99% of the code belongs to the xupload author Asgaroth.

"This action is Needless!"

Many of you may think that this CAction is needless, this is somehow true. You could create a controller like XuploadController.php have all the upload actions in there and pass this controller/action to the xupload url property. Even this case you are one step beyond, just create the XuploadController and use this action as in any other controller:

class MyController exnteds CController 
    public function actions()
        return array(
                //Assuming action exist in the extension folder

This code is not complicated neither is big enough. There are only 2 properties:

  • parent_id: Parent folder where the file will be uploaded.
  • path: Full path of the main uploading folder. Check code and EXUploadAction::init() for more informatin.
3 0
Viewed: 18 099 times
Version: Unknown (update)
Category: Tips
Written by: tydeas_dr
Last updated by: tydeas_dr
Created on: Apr 26, 2011
Last updated: 8 years ago
Update Article


View all history

Related Articles