Browse Source

修改根据临时文件id将临时文件保存在文件中方法逻辑

antshop
linyaostalker 5 years ago
parent
commit
fc782e23cd
  1. 14
      backend/modules/file/logic/file/FileManager.php
  2. 35
      backend/modules/goods/views/goods/express.php

14
backend/modules/file/logic/file/FileManager.php

@ -15,7 +15,7 @@ class FileManager
const TYPE_WORD = 4;//word文本
const TYPE_TXT = 5;//txt文本
public static $extension = [
private $extension = [
self::TYPE_IMAGE => ['jpg', 'png', 'jpeg'],
self::TYPE_VIDEO => ['mp4'],
self::TYPE_EXCEL => [],
@ -29,16 +29,14 @@ class FileManager
* @return array
* 根据文件拓展名在$extension中查找对应的文件类型,若不存在则返回false
*/
public function searchType($array, $keyword)
public function searchType($keyword)
{
foreach($array as $key => $value){
foreach ($value as $k => $v) {
if($v == $keyword){
return ['status' => true, 'info' => '操作成功', 'type' => $key];
}
foreach($this->extension as $key => $type){
if (in_array($keyword, $type)) {
return $key;
}
}
return ['status' => false, 'info' => '操作失败'];
return 0;
}
/**

35
backend/modules/goods/views/goods/express.php

@ -0,0 +1,35 @@
<?php
use yii\helpers\Url;
/* @var $this yii\web\View */
/* @var $model backend\modules\goods\models\ars\Goods */
/* @var $form yii\widgets\ActiveForm */
?>
<?= $form->field($model, 'coverImageId')->hiddenInput()->label('') ?>
<?= $form->field($model, 'coverImagePath')->widget(\iron\widgets\Upload::className(), [
'url' => 'upload',
'deleteUrl' => 'img-id-del',
'dragdropWidth'=> 800,
'afterSave' => 'save-file',
'maxCount' => 1,
'fillInAttribute' => 'coverImageId',
'model' => $model,
'previewConfig' => [
'url' => Url::to(['image-file', 'fileidstr' => $model->coverImageId, 'ruleverify' => $model->ruleVerify]),
],
])->label('商品封面图') ?>
<?= $form->field($model, 'detailImageId')->hiddenInput()->label('') ?>
<?= $form->field($model, 'detailImagePath')->widget(\iron\widgets\Upload::className(), [
'url' => 'upload',
'deleteUrl' => 'img-id-del',
'dragdropWidth'=> 800,
'afterSave' => 'save-file',
'maxCount' => 5,
'fillInAttribute' => 'detailImageId',
'model' => $model,
'previewConfig' => [
'url' => Url::to(['image-file', 'fileidstr' => $model->detailImageId, 'ruleverify' => $model->ruleVerify]),
],
])->label('商品详情图') ?>
Loading…
Cancel
Save