私はhttps://github.com/yiiext/uploadify-widgetを使用しています、と私はエラーHTTPエラーを解決しようと多くの時間を過ごす:500、と私はここにHTTPエラー:Yiiのフレームワークの500 uploadifyウィジェット
をデバッグする方法を何ideiaが表示されていませんprotected/views/admin/_form_photo.php
:私はアクションprotected/controllers/SwfUploadAction.php
を持って
<?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
$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); }'
)
));
?>
私はモデルprotected/models/UploadifyFile.php
を持っている
<?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()));
}
}
?>
とコントローラprotected/controllers/AdminController.php
からアクション:
function actions()
{
return array(
'SwfUpload' => array(
'class' => 'application.controllers.SwfUploadAction',
'folder' => 'images'
)
);
}
私はフラッシュの認証に問題があることができ、記事を読んで、私はforgerySession http://code.google.com/p/yiiext/source/browse/trunk/app/extensions/yiiext/filters/forgerySession/を使用する必要があり、私はそれを設定する方法が分かりません、事前に大きなおかげで!!!!
認証私はUserIdentity、データベース – mIRU
を投げています。私が知りたいのは、ユーザーがアクションにアクセスできるかどうかをどうやって確認するのですか? –