HiboxUploadController.php
2.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php
Yii::import("ext.xupload.models.UploadFileForm");
Yii::import("ext.xupload.models.UploadImageForm");
class HiboxUploadController extends Controller
{
public function actions()
{
return array(
// FLASH 上传
'upload'=>array(
'class' => 'application.extensions.swfupload.SWFUploadAction',
'path' => realpath(Yii::app()->getBasePath()."/../upload/common"),
),
// 文件类型上传
'uploadFile' => array(
'class' => 'ext.xupload.actions.UploadFileAction',
'subfolderVar' => 'file',
'path' => realpath(Yii::app()->getBasePath()."/../upload/files"),
),
// 图片类型上传
'uploadImage' => array(
'class' => 'ext.xupload.actions.UploadImageAction',
'subfolderVar' => 'image',
'path' => realpath(Yii::app()->getBasePath()."/../upload/images"),
),
);
}
/**
* 图片上传
*/
public function actionIndexUploadImage()
{
$model = new UploadImageForm;
$this->render('image', array(
'model' => $model,
'r' => null,
));
}
/**
* 文件上传
*/
public function actionIndexUploadFile()
{
$model = new UploadFileForm;
$this->render('file', array(
'model' => $model,
'r' => null,
));
}
/**
* 多文件上传
*/
public function actionIndexUploadMultiple()
{
$model = new UploadFileForm;
$this->render('multiple', array(
'model' => $model,
'r' => null,
));
}
/**
* 异常错误处理
*/
public function actionError()
{
if ($error = Yii::app()->errorHandler->error)
{
if (Yii::app()->request->isAjaxRequest)
{
echo $error['message'];
}
else
{
$this->render('error', $error);
}
}
}
}
?>