|
|
@ -8,6 +8,9 @@ use antgoods\goods\models\searchs\GoodsSearch; |
|
|
|
use yii\web\Controller; |
|
|
|
use yii\web\NotFoundHttpException; |
|
|
|
use yii\filters\VerbFilter; |
|
|
|
use common\models\ars\TemFile; |
|
|
|
use common\models\ars\File; |
|
|
|
use backend\logic\file\FileManager; |
|
|
|
|
|
|
|
/** |
|
|
|
* GoodsController implements the CRUD actions for Goods model. |
|
|
@ -34,7 +37,8 @@ class GoodsController extends Controller |
|
|
|
return [ |
|
|
|
'upload' => [ |
|
|
|
'class' => 'iron\actions\UploadAction', |
|
|
|
'path' => 'xls/' |
|
|
|
'path' => 'xls/', |
|
|
|
'maxSize' => 20480, |
|
|
|
] |
|
|
|
]; |
|
|
|
} |
|
|
@ -156,4 +160,26 @@ class GoodsController extends Controller |
|
|
|
'columns' => $searchModel->columns() |
|
|
|
]); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 处理文件上传成功后回调保存到临时文件表中 |
|
|
|
*/ |
|
|
|
public function actionSavefile() |
|
|
|
{ |
|
|
|
$data = Yii::$app->request->get('data'); |
|
|
|
$fileName = Yii::$app->request->get('fileName')[0]; |
|
|
|
|
|
|
|
if ($data['status'] == true) { |
|
|
|
$model = new TemFile(); |
|
|
|
$model->user_id = Yii::$app->user->identity->id; |
|
|
|
$model->name = $fileName; |
|
|
|
$type = Yii::$app->file->searchType(FileManager::$extension, pathinfo($data['path'])['extension']); |
|
|
|
if ($type != -1) { |
|
|
|
$model->type = $type; |
|
|
|
} |
|
|
|
$model->alias = $data['alias']; |
|
|
|
$model->path = $data['path']; |
|
|
|
$model->save(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |