本文整理匯總了PHP中source\LuLu::error方法的典型用法代碼示例。如果您正苦於以下問題:PHP LuLu::error方法的具體用法?PHP LuLu::error怎麽用?PHP LuLu::error使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類source\LuLu
的用法示例。
在下文中一共展示了LuLu::error方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: uploadFile
/**
*
* -path
* -url
* -name
* -new_name
* -temp_name
* -type
* -ext
* -size
* -message
*
* @param string $name the form name
* @return array
*/
public static function uploadFile($name)
{
LuLu::info($name, __METHOD__ . ',the form name is ' . $name);
$uploadedFile = UploadedFile::getInstanceByName($name);
if ($uploadedFile === null) {
return ['message' => '沒有文件'];
}
if ($uploadedFile->hasError) {
switch ($uploadedFile->error) {
case '1':
$error = '超過php.ini允許的大小。';
break;
case '2':
$error = '超過表單允許的大小。';
break;
case '3':
$error = '圖片隻有部分被上傳。';
break;
case '4':
$error = '請選擇圖片。';
break;
case '6':
$error = '找不到臨時目錄。';
break;
case '7':
$error = '寫文件到硬盤出錯。';
break;
case '8':
$error = 'File upload stopped by extension。';
break;
case '999':
default:
$error = '未知錯誤。';
}
LuLu::error($error, '上傳文件出錯');
return ['message' => $error];
}
$ymd = date("Ymd");
$save_path = \Yii::getAlias('@attachmentPath') . '/' . $ymd . "/";
$save_url = 'data/attachment/' . $ymd . "/";
if (!file_exists($save_path)) {
mkdir($save_path);
}
$file_name = $uploadedFile->getBaseName();
$file_ext = $uploadedFile->getExtension();
// 新文件名
$new_file_name = date("YmdHis") . '_' . rand(10000, 99999) . '.' . $file_ext;
$uploadedFile->saveAs($save_path . $new_file_name);
return ['path' => $save_path, 'url' => $save_url, 'name' => $file_name, 'new_name' => $new_file_name, 'ext' => $file_ext, 'temp_name' => $uploadedFile->tempName, 'type' => $uploadedFile->type, 'size' => $uploadedFile->size, 'message' => 'ok'];
}
示例2: actionLogin
public function actionLogin()
{
if (!LuLu::$app->user->isGuest) {
return $this->goHome();
}
$message = '';
$this->layout = false;
$model = new \source\models\LoginForm();
if ($model->load(LuLu::$app->request->post())) {
if ($model->login()) {
if ($this->rbacService->checkPermission('manager_admin')) {
return $this->goBack();
} else {
LuLu::$app->user->logout();
$message = '您沒有權限登錄管理係統';
LuLu::error("用戶名:{$model->username},密碼:{$model->password},{$message}", '登錄後台');
}
} else {
LuLu::error("用戶名:{$model->username},密碼:{$model->password},{$message}", '登錄後台');
}
}
return $this->render('login', ['model' => $model, 'message' => $message]);
}