Yii 1.1: A simple action for XUpload extension


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.


Total 1 comment

#3665 report it
Harry Tang at 2011/04/27 02:26am

Wow this is what I need.

Thank you so much

Leave a comment

Please to leave your comment.

Write new article
  • Written by: tydeas_dr
  • Category: Tips
  • Yii Version: 1.1
  • Votes: +3 / -1
  • Viewed: 16,382 times
  • Created on: Apr 26, 2011
  • Last updated: never
  • Tags: tips, xupload, caction