xupload : internal server error after using frontend-backend

before i set my project to backend and frontend architecture, this extension works fine. but now, it always show "500 error : internal server error" after uploading file, and the thumb image does not showed at all. but the file is uploaded correctly. does anyone know how to fix this?

thank you.

controller







    public function actionUpload($id=null) {

        Yii::import("xupload.models.XUploadForm");

        //Here we define the paths where the files will be stored temporarily

        $importFileRealPath = ImportFile::getImportFileRealPath();

        $importFileUrl = ImportFile::getImportFileURL();


        //kalau file ada, delete dulu

        $model=null;

        if($id!=null){

            $model=$this->loadModel($id);

            if(file_exists($importFileRealPath.$model->file_name)){

                unlink($importFileRealPath.$model->file_name);

            }                   

        }     

        

        //This is for IE which doens't handle 'Content-type: application/json' correctly

        header('Vary: Accept');

        if (isset($_SERVER['HTTP_ACCEPT']) && (strpos($_SERVER['HTTP_ACCEPT'], 'application/json') !== false)) {

            header('Content-type: application/json');

        } else {

            header('Content-type: text/plain');

        }


        //Here we check if we are deleting and uploaded file

        if (isset($_GET["_method"])) {

            if ($_GET["_method"] == "delete") {

                if ($_GET["file"][0] !== '.') {

                    $importFileFile = $importFileRealPath . $_GET["file"];

                    ImportFile::deleteFile($importFileUrl, $importFileFile);

                }

                echo json_encode(true);

            }

        } else {


            $attachment = new XUploadForm;

            $attachment->file = CUploadedFile::getInstance($attachment, 'file');

            //We check that the file was successfully uploaded

            if ($attachment->file !== null) {


                //Grab some data

                $attachment->mime_type = $attachment->file->getType();

                $attachment->size = $attachment->file->getSize();

                $attachment->name = $attachment->file->getName();


                //(optional) Generate a random name for our file

                $filename = md5(Yii::app()->user->id . microtime() . $attachment->name);

                $filename .= "." . $attachment->file->getExtensionName();


                if ($attachment->validate()) {


                    if($model==null){

                        //UNTUK ADD NEW

                        $importFile = new ImportFile();

                        $importFile->attributes = $_POST['ImportFile'];                

                    }

                    else{

                        //UNTUK UPDATE

                        $importFile=$model;

                    }


                    if($importFile->title==null){

                        $importFile->title = $attachment->name;

                    }

                    if($importFile->description==null){

                        $importFile->description = "";

                    } 


                    $importFile->file_name = $filename;           

                    $importFile->file_url = $importFileUrl . $filename;

                    $importFile->file_location = $importFileRealPath . $filename;

                    $importFile->save();


                    //Move our file to our temporary dir

                    $attachment->file->saveAs($importFileRealPath . $filename, false);


                    //Now we need to save this path to the user's session

                    if (Yii::app()->user->hasState('images')) {

                        $userImages = Yii::app()->user->getState('images');

                    } else {

                        $userImages = array();

                    }


                    $userPictures[] = array(

                        "path" => Yii::getPathOfAlias('webroot') . $importFileUrl . $filename,

                        //the same file or a thumb version that you generated

                        "thumb" => Yii::getPathOfAlias('webroot') . PictureSender::getNoImage(),

                        "filename" => $filename,

                        'size' => $attachment->size,

                        'mime' => $attachment->mime_type,

                        'name' => $filename,

                    );

                    Yii::app()->user->setState('images', $userImages);


                    //Now we need to tell our widget that the upload was succesfull

                    //We do so, using the json structure defined in

                    // https://github.com/blueimp/jQuery-File-Upload/wiki/Setup

                    echo json_encode(array(array(

                            "name" => $attachment->name,

                            "type" => $attachment->mime_type,

                            "size" => $attachment->size,

                            "url" => Yii::app()->getBaseUrl(true) . $importFileUrl . $filename,

                            "thumbnail_url" => Yii::app()->getBaseUrl(true) . PictureSender::getNoImage(),

                            "delete_url" => $this->createUrl("tx/importfile/upload", array(

                                "_method" => "delete",

                                "file" => $filename

                            )),

                            "delete_type" => "POST"

                    )));                




                } else {

                    //If the upload failed for some reason we log some data and let the widget know

                    echo json_encode(array(

                        array("error" => $attachment->getErrors('file'),

                    )));

                    Yii::log("XUploadAction: " . CVarDumper::dumpAsString($attachment->getErrors()), CLogger::LEVEL_ERROR, "xupload.actions.XUploadAction"

                    );

                }

            } else {

                throw new CHttpException(500, "Could not upload file");

            }

        }

    }



_form

[b]

[/b]





<?php $form=$this->beginWidget('bootstrap.widgets.BsActiveForm', array(

    'id'=>'import-file-form',

    // Please note: When you enable ajax validation, make sure the corresponding

    // controller action is handling ajax validation correctly.

    // There is a call to performAjaxValidation() commented in generated controller code.

    // See class documentation of CActiveForm for details on this.

    'enableAjaxValidation'=>false,

    'htmlOptions' => array(

        'enctype' => 'multipart/form-data',

    ),      

)); ?>


    <p class="help-block">Fields with <span class="required">*</span> are required.</p>


    <?php echo $form->errorSummary($model); ?>

    <?php echo $form->textAreaControlGroup($model,'description',array('rows'=>6)); ?>

    <?php

                    $this->widget('xupload.XUpload', array(

                        'url' => Yii::app()->createUrl('tx/importfile/upload'),

                        //our XUploadForm

                        'model' => $xuploadform,

                        //We set this for the widget to be able to target our own form

                        'htmlOptions' => array('id' => 'import-file-form'),

                        'attribute' => 'file',

                        'multiple' => false,

                        //Note that we are using a custom view for our widget

                        //Thats becase the default widget includes the 'form' 

                        //which we don't want here

//                        'formView' => 'application.views.frontend.tx.xuploadform._xuploadform',

                    ));    

    ?>


<?php $this->endWidget(); ?>