SWFUpload opens a new PHP session when connecting to Apache and uploading file(s) to web server's file system.
Solution:
1. Remember to pass in postParams
$this->widget('application.extensions.swfupload.CSwfUpload', array(
'jsHandlerUrl'=>'js/swfupload/handlers.js',
'postParams'=>array('PHPSESSID'=>session_id()),
'config'=>array( ...
2. In the Controller, modify accessRules() to allow any user to call the action that is going to be used by SWFUpload.
Below is are sample codes in my View file:
$uploadUrl=$this->createUrl('photo/swfupload');
$this->widget('application.extensions.swfupload.CSwfUpload', array(
'jsHandlerUrl'=>'js/swfupload/handlers.js',
'postParams'=>array('PHPSESSID'=>session_id()),
'config'=>array(
'debug'=>false,
'use_query_string'=>true,
'upload_url'=>$uploadUrl,
'file_size_limit'=>'5 MB',
'file_types'=>'*.jpg;*.png;*.gif',
'file_types_description'=>'Image Files',
'file_upload_limit'=>0,
'file_queue_error_handler'=>'js:fileQueueError',
'file_dialog_complete_handler'=>'js:fileDialogComplete',
'upload_progress_handler'=>'js:uploadProgress',
'upload_error_handler'=>'js:uploadError',
'upload_success_handler'=>'js:uploadSuccess',
'upload_complete_handler'=>'js:uploadComplete',
'custom_settings'=>array('progressTarget'=>'divFileProgressContainer','cancelButtonId'=>'btnCancel'),
'button_placeholder_id'=>'swfupload',
'button_image_url'=>'js/swfupload/images/TestImageNoText_100x20.png',
'button_width'=>50,
'button_height'=>20,
'button_text'=>' ',
'button_text_style'=>'.button { font-family: "Lucida Sans Unicode", "Lucida Grande", sans-serif; font-size: 9pt; text-align: center; }',
'button_text_top_padding'=>0,
'button_text_left_padding'=>0,
'button_window_mode'=>'js:SWFUpload.WINDOW_MODE.TRANSPARENT',
'button_cursor'=>'js:SWFUpload.CURSOR.HAND',
),
)
);
?>
$uploadUrl); ?>
As you can see, photo/swfupload is my controller/action pair。
So, in photoController file, we shall change the accessRules() function to allow anyone to call actionSwfupload(). Below are my sample codes:
public function accessRules()
{
return array(
array('allow', // allow all users to perform 'index' and 'view' actions
'actions'=>array('index','view','swfupload'),
'users'=>array('*'),
),
);
}
Please feel free to share your experience on this issue.