Asgaroth / xupload

XUpload extension for Yii Framework

Home Page:http://www.yiiframework.com/extension/xupload/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

subfolderVar issuse

wartur opened this issue · comments

Hello.

I find mistake. as i read in documentation XUploadAction.subfolderVar must support set custom subfolder for upload. Example this hint create session independence code.
public function actions()
{
return array(
'upload'=>array(
'class'=>'xupload.actions.XUploadAction',
'path' => Yii::getPathOfAlias('webroot') . '/data/uploads',
'publicPath' => '/data/uploads',
'subfolderVar' => Yii::app()->session->sessionID,
),
);
}

Now see this code in XUploadAction::init()

if( $this->subfolderVar === null ) {
$this->_subfolder = Yii::app( )->request->getQuery( $this->subfolderVar, date( "mdY" ) );
} else if($this->subfolderVar !== false ) {
$this->_subfolder = date( "mdY" );
}

I not see this code for setup custom folder
this is my fix:

if( $this->subfolderVar === null ) {
$this->_subfolder = Yii::app( )->request->getQuery( $this->subfolderVar, date( "mdY" ) );
} else if($this->subfolderVar === false ) {
$this->_subfolder = date( "mdY" );
} else {
$this->_subfolder = $this->subfolderVar; //fix: custom directory
}

i think good fix. take to trunk.

thanks for attentions, have fun! =)

The way you sue subfolder var si different, subfolerVar mainly tells the action what "var" from the request params to use as the folder's name.

In this case, if you want to use the session_id, you'd have to pass it in the query string.

ie your request should look like: myapp.com/upload/session_id=123abc

And in the XUploadAction configuration, you'd say the subfolderVar is "session_id"