meTables上传文件设置
2021-02-21 14:07:19
views
{
title: "发票照片",
data: "BILLPIC",
edit: {
type: "file",
options: {
"id": "file",
"name": "UploadForm[BILLPIC]",
"input-name": "BILLPIC",
"input-type": "ace_file",
"file-name": "BILLPIC",
}
},
},
{
title: "图书照片",
data: "BOOKPIC",
edit: {
type: "file",
options: {
"id": "file1",
"name": "UploadForm[BOOKPIC]",
"input-name": "BOOKPIC",
"input-type": "ace_file",
"file-name": "BOOKPIC",
}
},
},
Controller
public $strUploadPath = '../uploads/pictures/';
//上传路径
//重新定义上传路径
public function init(){
$dirName = $this->strUploadPath.MyFunc_GetNow('dir').'/';
\yii\helpers\FileHelper::createDirectory($dirName);
$this->strUploadPath = $dirName;
}
vendor\jinxing\yii2-admin\src\models\forms\UploadForm.php
//
public $BILLPIC;
public $BOOKPIC;
public function scenarios()
{
return [
'BILLPIC' => ['BILLPIC'],
'BOOKPIC' => ['BOOKPIC'],
];
}
// 验证规则
public function rules()
{
return [
[['attachment'], 'file', 'extensions' => \Yii::$app->params['UploadFileExt_BackForm'], 'on' => 'attachment', "checkExtensionByMimeType" => false],
[['BILLPIC'], 'image', 'extensions' => ['png', 'jpg', 'gif', 'jpeg'], 'on' => 'BILLPIC', "checkExtensionByMimeType" => false],
[['BOOKPIC'], 'image', 'extensions' => ['png', 'jpg', 'gif', 'jpeg'], 'on' => 'BOOKPIC', "checkExtensionByMimeType" => false],
];
}
{
title: "发票照片",
data: "BILLPIC",
edit: {
type: "file",
options: {
"id": "file",
"name": "UploadForm[BILLPIC]",
"input-name": "BILLPIC",
"input-type": "ace_file",
"file-name": "BILLPIC",
}
},
},
{
title: "图书照片",
data: "BOOKPIC",
edit: {
type: "file",
options: {
"id": "file1",
"name": "UploadForm[BOOKPIC]",
"input-name": "BOOKPIC",
"input-type": "ace_file",
"file-name": "BOOKPIC",
}
},
},
Controller
public $strUploadPath = '../uploads/pictures/';
//上传路径
//重新定义上传路径
public function init(){
$dirName = $this->strUploadPath.MyFunc_GetNow('dir').'/';
\yii\helpers\FileHelper::createDirectory($dirName);
$this->strUploadPath = $dirName;
}
vendor\jinxing\yii2-admin\src\models\forms\UploadForm.php
//
public $BILLPIC;
public $BOOKPIC;
public function scenarios()
{
return [
'BILLPIC' => ['BILLPIC'],
'BOOKPIC' => ['BOOKPIC'],
];
}
// 验证规则
public function rules()
{
return [
[['attachment'], 'file', 'extensions' => \Yii::$app->params['UploadFileExt_BackForm'], 'on' => 'attachment', "checkExtensionByMimeType" => false],
[['BILLPIC'], 'image', 'extensions' => ['png', 'jpg', 'gif', 'jpeg'], 'on' => 'BILLPIC', "checkExtensionByMimeType" => false],
[['BOOKPIC'], 'image', 'extensions' => ['png', 'jpg', 'gif', 'jpeg'], 'on' => 'BOOKPIC', "checkExtensionByMimeType" => false],
];
}