Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2012/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
HTTP错误:yii框架的500 uploadify小部件_Yii_Uploadify - Fatal编程技术网

HTTP错误:yii框架的500 uploadify小部件

HTTP错误:yii框架的500 uploadify小部件,yii,uploadify,Yii,Uploadify,我正在使用,我花了很多时间试图解决错误HTTP错误:500,我不知道如何调试 这里是viewprotected/views/admin/\u form\u photo.php: <?php $this->widget('ext.uploadify.EUploadifyWidget', array( // you can either use it for model attribute 'model' => new UploadifyFile, 'att

我正在使用,我花了很多时间试图解决错误HTTP错误:500,我不知道如何调试

这里是view
protected/views/admin/\u form\u photo.php

<?php
$this->widget('ext.uploadify.EUploadifyWidget', array(
    // you can either use it for model attribute
    'model' => new UploadifyFile,
    'attribute' => 'file1',
    // or just for input field
    'name' => 'UploadifyFile_file1',
    // the name of the POST parameter where save session id
    'sessionParam' => 'PHP_SESSION_ID',
    // extension [options](http://www.uploadify.com/documentation/)
    'options' => array(
        'fileExt' => '*.jpg;*.png;*.gif',
        'script' => $this->createUrl('SwfUpload'),
        'debug' => true,
        'auto' => false,
        'multi' => true,
        'buttonText' => 'Upload Images',
        'onError' => 'js:function (event,ID,fileObj,errorObj) { alert(errorObj.type + \' Error: \' + errorObj.info); }'
    )
));
?>
<?php

class UploadifyFile extends CFormModel
{
    public $uploadifyFile;

    public function rules()
    {
        return array(
            array(
                'uploadifyFile',
                'file',
                'maxSize' => 1024 * 1024 * 1024,
                'types' => 'jpg, png, gif, txt'
            )
        );
    }
}

?>
<?php
    class SwfUploadAction extends CAction
    {
        public $folder;

        public function run()
        {
            $folder = $this->folder;

            if ($folder === false) {
                throw new CException(Yii::t(__CLASS__, "Folder does not exists.", array()));
            }
            if (isset($_FILES['UploadifyFile']) === true) {
                $model                = new UploadifyFile;
                $model->attributes    = array(
                    'uploadifyFile' => ''
                );
                $model->uploadifyFile = CUploadedFile::getInstance($model, 'uploadifyFile');
                if ($model->validate() === false) {
                    throw new CException(Yii::t(__CLASS__, "Invalid file.", array()));
                }
                if (!$model->uploadifyFile->saveAs($folder . '/' . $model->uploadifyFile->getName())) {
                    throw new CException(Yii::t(__CLASS__, "Upload error.", array()));
                } else {
                    die("Upload success");
                }
            } else {
                throw new CException(Yii::t(__CLASS__, "File not sent.", array()));
            }
            throw new CException(Yii::t(__CLASS__, 'Unknown error.', array()));
        }
    }

    ?>
function actions()
{
    return array(
        'SwfUpload' => array(
            'class' => 'application.controllers.SwfUploadAction',
            'folder' => 'images'
        )
    );
}
我的操作
受保护/controllers/SwfUploadAction.php

<?php
$this->widget('ext.uploadify.EUploadifyWidget', array(
    // you can either use it for model attribute
    'model' => new UploadifyFile,
    'attribute' => 'file1',
    // or just for input field
    'name' => 'UploadifyFile_file1',
    // the name of the POST parameter where save session id
    'sessionParam' => 'PHP_SESSION_ID',
    // extension [options](http://www.uploadify.com/documentation/)
    'options' => array(
        'fileExt' => '*.jpg;*.png;*.gif',
        'script' => $this->createUrl('SwfUpload'),
        'debug' => true,
        'auto' => false,
        'multi' => true,
        'buttonText' => 'Upload Images',
        'onError' => 'js:function (event,ID,fileObj,errorObj) { alert(errorObj.type + \' Error: \' + errorObj.info); }'
    )
));
?>
<?php

class UploadifyFile extends CFormModel
{
    public $uploadifyFile;

    public function rules()
    {
        return array(
            array(
                'uploadifyFile',
                'file',
                'maxSize' => 1024 * 1024 * 1024,
                'types' => 'jpg, png, gif, txt'
            )
        );
    }
}

?>
<?php
    class SwfUploadAction extends CAction
    {
        public $folder;

        public function run()
        {
            $folder = $this->folder;

            if ($folder === false) {
                throw new CException(Yii::t(__CLASS__, "Folder does not exists.", array()));
            }
            if (isset($_FILES['UploadifyFile']) === true) {
                $model                = new UploadifyFile;
                $model->attributes    = array(
                    'uploadifyFile' => ''
                );
                $model->uploadifyFile = CUploadedFile::getInstance($model, 'uploadifyFile');
                if ($model->validate() === false) {
                    throw new CException(Yii::t(__CLASS__, "Invalid file.", array()));
                }
                if (!$model->uploadifyFile->saveAs($folder . '/' . $model->uploadifyFile->getName())) {
                    throw new CException(Yii::t(__CLASS__, "Upload error.", array()));
                } else {
                    die("Upload success");
                }
            } else {
                throw new CException(Yii::t(__CLASS__, "File not sent.", array()));
            }
            throw new CException(Yii::t(__CLASS__, 'Unknown error.', array()));
        }
    }

    ?>
function actions()
{
    return array(
        'SwfUpload' => array(
            'class' => 'application.controllers.SwfUploadAction',
            'folder' => 'images'
        )
    );
}

我读过一些文章说,flash的身份验证可能会出现问题,我必须使用forgerySession,我不知道如何配置它,提前表示感谢

解决这一问题的最简单方法是允许未经授权访问该操作。也就是说,如果您在应用程序中执行身份验证检查,请为未经授权的特定上载操作返回true


为了提出更具体的答案,我需要知道您是如何在应用程序中进行身份验证的。

我正在进行的身份验证抛出了UserIdentity、Database我知道,我想知道的是,如何检查用户是否可以访问某个操作?