Commit a43fce4468c8b52611e2ca97be546dd460fbb8be

Authored by 曹明
1 parent 2f37a45c
Exists in master

防伪标签激活视频文件上传兼容IPHON手机视频。

app-wx/modules/smart/controllers/DefaultController.php
... ... @@ -47,12 +47,21 @@ class DefaultController extends BaseController
47 47 }
48 48 $type = $_FILES["file"]["type"];
49 49 $typeArr = explode('/', $type);
  50 + Log::DEBUG("上传文件信息:" . json_encode($_FILES));
50 51 if ('image' !== $typeArr[0] && 'video' !== $typeArr[0] && 'audio' !== $typeArr[0]) {
51 52 $e->message = '只能上传MP4视频和图片文件';
52 53 return $this->renderJson($e);
53 54 }
  55 +
54 56 $fileArr = explode('.', $_FILES["file"]['name']);
55 57 $fileExt = end($fileArr);
  58 +
  59 + // 兼容苹果手机mov视频文件
  60 + if (!in_array(strtolower($fileExt), ["jpg", "gif", "png", "jpeg", "ico", "bmp", "mp4", "mov"])) {
  61 + $e->message = '该文件被限制不能上传';
  62 + return $this->renderJson($e);
  63 + }
  64 +
56 65 // 判断文件大小
57 66 $fileSize = $_FILES["file"]["size"] / (1024 * 1024);
58 67 if (strtoupper($fileExt) == "MP4") {
... ... @@ -76,12 +85,12 @@ class DefaultController extends BaseController
76 85 move_uploaded_file($_FILES["file"]['tmp_name'], $saveFilePath);
77 86 $ossPath = ImageManager::getTempImgPath($fileExt);
78 87 ImageManager::add($saveFilePath, $ossPath);
79   - if (strtoupper($fileExt) == "MP4") {
80   - $tmpMinFile = $this->site->base_url. "/i/enter/vedio.jpg";
  88 + if (strtoupper($fileExt) == "MP4" || strtoupper($fileExt) == "MOV") {
  89 + $tmpMinFile = $this->site->base_url. "/i/enter/vedio.png";
81 90 } else {
82 91 $tmpMinFile = ImageManager::getUrl($ossPath, ImageManager::$STYLE_180);
83 92 }
84   - Log::DEBUG("上传文件信息:" . json_encode($_FILES));
  93 +
85 94 // 删除ECS服务器文件
86 95 @unlink($saveFilePath);
87 96 // 上传到OSS
... ...
app-wx/modules/smart/views/default/pages/enter-template.php
... ... @@ -24,7 +24,7 @@ $baseUrl = Url::base(true);
24 24 </div>
25 25 <div class="space-line"></div>
26 26 <div class="input-item-cls">
27   - <label class="pub-title">上传商品视频<span class="require-cls">(视频<10M mp4格式)</span></label>
  27 + <label class="pub-title">上传商品视频<span class="require-cls">(视频<10M mp4|mov格式)</span></label>
28 28 <div class="img-box-cls">
29 29 <ul id ="vedio-list" style="overflow: hidden;margin-top:0.5rem; margin-bottom: 0.5rem;">
30 30 <li class="upload-vedio-li upload-vedio-btn-li">
... ...
app-wx/web/i/enter/vedio.png 0 → 100644

9.91 KB