Преглед изворни кода

上传网络图片到服务器本地

huwhois пре 2 година
родитељ
комит
258c5ff5ba

+ 22 - 0
app/common/facade/FileUtils.php

@@ -0,0 +1,22 @@
+<?php
+declare(strict_types=1);
+
+namespace app\common\facade;
+
+use think\Facade;
+
+/**
+ * @see \app\common\utils\FileUtils
+ * @package app\common\facade
+ * @mixin \app\common\utils\FileUtils
+ * @method static \think\Image waterMark()
+ * @method static \think\Image thumbnail()
+ * @method static \think\file\UploadedFile downloadUrlImg()
+ */
+class FileUtils extends Facade
+{
+    protected static function getFacadeClass()
+    {
+        return 'app\common\utils\FileUtils';
+    }
+}

+ 15 - 15
app/common/model/FileManager.php

@@ -5,7 +5,6 @@ namespace app\common\model;
 
 use think\facade\Config;
 use think\File;
-use think\Image;
 use think\exception\FileException;
 
 class FileManager extends \think\Model
@@ -39,7 +38,7 @@ class FileManager extends \think\Model
         return self::where($where)->field('fileid,filename,filesize,filetime,filepath,fileextension,title,username')->order('fileid DESC')->paginate(['list_rows'=>$limit, 'query' => $param]);
     }
 
-    public static function saveFile(\think\File $file)
+    public static function saveFile(File $file)
     {
         $fileinfo = self::where('hash_md5', $file->md5())->find();
 
@@ -64,32 +63,33 @@ class FileManager extends \think\Model
         $fileinfo->save();
     }
 
-    public static function saveFileInfo($file, $id = 0, $cjid = 0, $username = 'system')
+    public static function saveFileInfo($file, $savename, $originalName = '', $id = 0, $cjid = 0, $username = 'system')
     {
         if (is_string($file)) {
-            $file = new \SplFileInfo($file);
+            $file = new File($file);
         }
+
         if (!$file->isFile()) {
             throw new FileException('file not exist');
         }
 
-        $publicRootPath = str_replace('\\', '/', Config::get('filesystem.disks.public.root'));
-
         $publicUrlPath =  Config::get('filesystem.disks.public.url');
 
-        
         $fileinfo = new static();
-        
-        $fileinfo->filename      = $file->getFilename();
+                
+        $fileinfo->filename      = basename($savename);
+        $fileinfo->filepath      = $publicUrlPath . '/'. $savename;
+        $fileinfo->title         = $originalName;
+        $fileinfo->id            = $id;
+        $fileinfo->cjid          = $cjid;
+        $fileinfo->username      = $username;
         $fileinfo->filesize      = $file->getSize();
         $fileinfo->filetime      = $file->getCTime();
-        $fileinfo->filepath      = $publicUrlPath . str_replace($publicRootPath, '', $file->getPathname());
-        $fileinfo->fileextension = $file->getExtension();
+        $fileinfo->fileextension = $file->extension();
         $fileinfo->hash_md5      = $file->md5();
-        $fileinfo->username      = $id;
-        $fileinfo->username      = $cjid;
-        $fileinfo->username      = $username;
-
+        
         $fileinfo->save();
+
+        return $fileinfo;
     }
 }

+ 186 - 0
app/common/utils/FileUtils.php

@@ -0,0 +1,186 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * 文件 utils
+ *
+ * @version      0.0.1
+ * @author      by huwhois
+ * @time        20228/10
+ */
+
+namespace app\common\utils;
+
+use think\Image;
+use think\Exception;
+use think\File;
+use think\image\Exception as ImageException;
+use think\facade\Config;
+use think\file\UploadedFile;
+
+class FileUtils
+{
+    /**
+     * 图片添加水印
+     * @param File $file  要处理的文件
+     * @param int $type  水印类型 0 图片水印, 1 文字水印 
+     * @param string $waterimg  图片水印内容
+     * @param string $watertext  文字水印内容
+     * @param string $fonttype  水印文字类型
+     * @param int $fontsize  水印文字大小
+     * @param string $fontcolor  水印文字颜色
+     * @return Image  返回图片对象
+     */
+    public function waterMark(
+        Image $image,
+        int $type = 0,
+        string $watermark = '',
+        string $watertext = '',
+        string $fonttype = '',
+        int $fontsize = 0,
+        string $fontcolor = '#ffffff30'
+    ): Image {
+        if ($type == 0) {
+            $watermark = $watermark ?: Config::get('filesystem.water.watermark');
+            $image->water($watermark);
+        } else {
+            $watetext = $watertext ?: Config::get('filesystem.water.watertext');
+            $fonttype = $fonttype ?: Config::get('filesystem.water.fonttype');
+            $fontsize = $fontsize ?: (int) Config::get('filesystem.water.fontsize');
+            $fontcolor = $fontcolor ?: (int) Config::get('filesystem.water.fontcolor');
+
+            $image->text($watetext, $fonttype, $fontsize, $fontcolor);
+        }
+
+        return $image;
+    }
+
+    /**
+     * 生成缩略图
+     * @param Image $image  要处理的文件
+     * @param int $width 缩略图宽值, 默认 384px;
+     * @param int $height 缩略图高值, 默认 224px;
+     * @param int $type 缩略图裁剪方式, 默认值 1,固定尺寸缩放; 其他: 1,等比例缩放;2,缩放后填充;3,居中裁剪;4,左上角裁剪;5,右下角裁剪
+     * @param string $t_suffix  缩略图后缀
+     * @return Image  返回图片对象
+     */
+    public function thumbnail(Image $image, string $thumbname, int $width = 384, int $height = 224, int $type = 1)
+    {
+        $image->thumb($width, $height, $type)->save('./storage/' . $thumbname);
+
+        return $image;
+    }
+
+    /**
+     * 保存远程图片到本地
+     */
+    public function downloadUrlImg(string $url)
+    {
+        $ch = curl_init($url);
+        curl_setopt($ch, CURLOPT_HEADER, 0);
+        curl_setopt($ch, CURLOPT_NOBODY, 0); // 只取body头
+        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
+        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
+        curl_setopt($ch, CURLOPT_NOSIGNAL, 1);
+        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+
+        $package = curl_exec($ch);
+        $httpinfo = curl_getinfo($ch);
+
+        curl_close($ch);
+
+        // halt($httpinfo);
+        $imageAll = array_merge(array(
+            'imgBody' => $package
+        ), $httpinfo);
+        if ($httpinfo['download_content_length'] > 4 * 1024 * 1024) {
+            throw new Exception("文件太大", 1);
+        }
+
+        $type = null;
+
+        $originalName = "";
+
+        switch ($imageAll['content_type']) {
+            case 'image/gif':
+                $type = "gif";
+                break;
+            case 'image/webp':
+                $type = "webp";
+                break;
+            case 'image/jpeg':
+                $type = "jpg";
+                break;
+            case 'image/png':
+                $type = "png";
+                break;
+            default:
+                $type = null;
+                break;
+        }
+
+        // 腾讯公众号图片
+        if (strpos($url, 'qpic.cn') !== false) {
+            $urls = parse_url($url);
+
+            if (isset($urls['query'])) {
+                $query_arr = [];
+
+                parse_str($urls['query'], $query_arr);
+
+                $type = isset($query_arr['wx_fmt']) ? $query_arr['wx_fmt'] : null;
+
+                $type = $type == 'jpeg' ? 'jpg' : $type;
+            }
+        }
+
+        if (!$type) {
+            throw new Exception("不支持的文件后缀", 1);
+        }
+
+        $originalName = pathinfo($url, PATHINFO_EXTENSION) ? basename($url) : basename($url) . '.' . $type;
+
+        $temp =  app()->getRuntimePath() . 'temp';
+
+        if (!file_exists($temp)) {
+            mkdir($temp, 0755);
+        }
+        
+        $tempname = $temp . DIRECTORY_SEPARATOR . 'php' . substr(str_shuffle('0123456789abcdefghijklmnopqrstuvwxyz'), 0, 6) . '.tmp';
+
+        file_put_contents($tempname, $imageAll["imgBody"]);
+
+        return new UploadedFile($tempname, $originalName, $imageAll["content_type"]);
+    }
+
+    /**
+     * 遍历获取目录下的指定类型的文件
+     * @param $path
+     * @param $allowFiles  png|jpg|jpeg|gif|bmp|webp
+     * @param array $files
+     * @return array
+     */
+    public static function getFiles($path, $allowFiles = 'png|jpg|jpeg|gif|bmp|webp', &$files = array())
+    {
+        if (!is_dir($path)) return null;
+        if (substr($path, strlen($path) - 1) != '/') $path .= '/';
+        $handle = opendir($path);
+        while (false !== ($file = readdir($handle))) {
+            if ($file != '.' && $file != '..') {
+                $path2 = $path . $file;
+                if (is_dir($path2)) {
+                    self::getFiles($path2, $allowFiles, $files);
+                } else {
+                    if (preg_match("/\.(" . $allowFiles . ")$/i", $file)) {
+                        $files[] = array(
+                            'url' => substr($path2, strlen(app()->getRootPath() . '/public') - 1),
+                            'mtime' => filemtime($path2)
+                        );
+                    }
+                }
+            }
+        }
+        return $files;
+    }
+}

+ 81 - 47
app/sys/controller/FileManager.php

@@ -16,14 +16,15 @@ use Exception;
 use UnexpectedValueException;
 use DirectoryIterator;
 use think\facade\View;
+use think\facade\Config;
 use think\File;
 use think\Image;
-use think\facade\Config;
 use think\exception\ValidateException;
+use think\file\UploadedFile;
 
 use app\common\service\FileService;
 use app\common\model\FileManager as FileManagerModel;
-use think\file\UploadedFile;
+use app\common\facade\FileUtils;
 
 class FileManager extends Base
 {
@@ -294,9 +295,9 @@ class FileManager extends Base
     {
         if ($this->request->isPost()) {
             $file = $this->request->file('upload_file');
-
+            halt($file);
             if ($file) {
-                // try {
+                try {
                     validate(
                         [
                             'file' => [
@@ -312,9 +313,15 @@ class FileManager extends Base
                         ]
                     )->check(['file' => $file]);
 
-                    $savename =  str_replace('\\', '/', $file->hashName()) ;
+                    $urlpath = Config::get('filesystem.disks.public.url');
+
+                    $username = $this->getSysUser()->username;
 
+                    $savename =  str_replace('\\', '/', $file->hashName());
 
+                    $originalName = $file->getOriginalName();
+
+                    $thumbname = "";
 
                     if ($thumb == true) {
                         $image = Image::open($file);
@@ -322,44 +329,40 @@ class FileManager extends Base
                         $image->thumb($width, $height, 1);
 
                         $ext = $file->extension();
-
-                        $thumbname = str_replace('.' . $ext, '',  $savename) . $this->t_suffix . '.' . $ext;    
-
+                        
                         if ($original == true) {
                             \think\facade\Filesystem::disk('public')->putFileAs('/', $file, $savename);
+                            
+                            $thumbname = str_replace('.' . $ext, '',  $savename) . $this->t_suffix . '.' . $ext;
+
+                            $savepath = str_replace('\\', '/', Config::get('filesystem.disks.public.root') . '/' . $thumbname);
+
+                            $image->save($savepath);
+                            
+                            FileManagerModel::saveFileInfo($savepath, $thumbname, $originalName, $id, $cjid, $username);
+
+                            $thumbname = $urlpath . '/' . $thumbname;
                         } else {
-                            $thumbname = str_replace('.' . $ext, '',  $thumbname) . $this->t_suffix . '.' . $ext;
-                            $savename = $thumbname;
+                            $image->save(Config::get('filesystem.disks.public.root') . '/' . $savename);
                         }
-                        $image->save(Config::get('filesystem.disks.public.root') . '/' . $thumbname);                      
                     } else {
                         \think\facade\Filesystem::disk('public')->putFileAs('/', $file, $savename);
                     }
 
-                    halt($savename);
+                    $fileinfo = FileManagerModel::saveFileInfo($file, $savename, $originalName, $id, $cjid, $username);
 
-                    $fileinfo = new FileManagerModel();
-                    
-                    $fileinfo->title         = $file->getOriginalName();
-                    $fileinfo->filesize      = $file->getSize();
-                    $fileinfo->filetime      = $file->getCTime();
-                    $fileinfo->fileextension = $file->extension();
-                    $fileinfo->hash_md5      = $file->md5();
-                    $fileinfo->filepath      = Config::get('filesystem.disks.public.url') . '/' . $savename;
-                    $fileinfo->filename      = basename($savename); 
-                    $fileinfo->username      = $this->getSysUser()->username;
-                    $fileinfo->infoid        =  $id;
-                    $fileinfo->cjid          =  $cjid;
-                    
-                    $fileinfo->save();
-                    // $res = FileManagerModel::dealUploadImg($file, $savename, $water, $thumb, $width, $height, $overwrite, $id, $cjid);
-
-                    // return json(array_merge(['code' => 0, 'img_id' => $img_id,], $res));
-                // } catch (ValidateException $e) {
-                //     $this->error($e->getMessage());
-                // } catch (Exception $e) {
-                //     $this->error($e->getMessage());
-                // }
+                    return json([
+                        'code'    => 0,
+                        'img_id'  => $img_id,
+                        'picname' => $fileinfo->filepath,
+                        'thumb'   => $thumbname
+
+                    ]);
+                } catch (ValidateException $e) {
+                    $this->error($e->getMessage());
+                } catch (Exception $e) {
+                    $this->error($e->getMessage());
+                }
             } else {
                 $this->error('图片不能为空');
             }
@@ -376,29 +379,60 @@ class FileManager extends Base
      * @param int $height       缩略图最大高
      * @param bool $overwrite   生成缩略图后是否保存原图
      */
-    public function uploadUrlImg(string $img_id = 'picture', $water = false, $thumb = false, $width = 400, $height = 300, $overwrite = false)
+    public function uploadUrlImg(string $img_id = 'picture', $thumb = false, $width = 400, $height = 300,
+        $original = false, $id = 0, $cjid = 0)
     {
         if ($this->request->isPost()) {
             $urlImg = $this->request->param('url_file');
 
             if ($urlImg) {
                 try {
-                    $fileService = new FileService();
+                    $file = FileUtils::downloadUrlImg($urlImg);
+                    
+                    $urlpath = Config::get('filesystem.disks.public.url');
 
-                    $file = $fileService->downloadUrlImg($urlImg);
+                    $username = $this->getSysUser()->username;
 
-                    $arr = $this->dealUploadImg($file, $thumb, $width, $height, $overwrite);
+                    $savename =  str_replace('\\', '/', $file->hashName());
 
-                    @unlink($file->realPath);
+                    $originalName = $file->getOriginalName();
 
-                    return array_merge(
-                        [
-                            'code' => 0,
-                            'img_id' => $img_id,
-                            'picture_url' => Config::get('filesystem.disks.public.url') . '/'
-                        ],
-                        $arr
-                    );
+                    $thumbname = "";
+
+                    if ($thumb == true) {
+                        $image = Image::open($file);
+                        
+                        $image->thumb($width, $height, 1);
+
+                        $ext = $file->extension();
+                        
+                        if ($original == true) {
+                            \think\facade\Filesystem::disk('public')->putFileAs('/', $file, $savename);
+                            
+                            $thumbname = str_replace('.' . $ext, '',  $savename) . $this->t_suffix . '.' . $ext;
+
+                            $savepath = str_replace('\\', '/', Config::get('filesystem.disks.public.root') . '/' . $thumbname);
+
+                            $image->save($savepath);
+                            
+                            FileManagerModel::saveFileInfo($savepath, $thumbname, $originalName, $id, $cjid, $username);
+
+                            $thumbname = $urlpath . '/' . $thumbname;
+                        } else {
+                            $image->save(Config::get('filesystem.disks.public.root') . '/' . $savename);
+                        }
+                    } else {
+                        \think\facade\Filesystem::disk('public')->putFileAs('/', $file, $savename);
+                    }
+                    $fileinfo = FileManagerModel::saveFileInfo($file, $savename, $originalName, $id, $cjid, $username);
+ 
+                    return json([
+                        'code'    => 0,
+                        'img_id'  => $img_id,
+                        'picname' => $fileinfo->filepath,
+                        'thumb'   => $thumbname
+
+                    ]);
                 } catch (\think\exception\ValidateException $e) {
                     $this->error($e->getMessage());
                 }

+ 106 - 51
view/sys/file_manager/uploadimg.html

@@ -88,6 +88,7 @@
         <span>本地上传</span>
         <span>网络文件上传</span>
         <a onclick="onlinepicture(1)"><span>服务器图片选择</span></a>
+        <input type="hidden" name="layer" id="layer" value="{$layer}">
     </div>
     <div class="tabCon">
         <div class="step1 active" style="margin-left:30px;">
@@ -102,7 +103,7 @@
                 <div class="row cl" style="margin-top:20px;">
                     <label class="form-label col-xs-2 col-sm-2">
                         <span class="c-red">*</span>本地上传:</label>
-                    <div class="formControls col-xs-4 col-sm-4">
+                    <div class="formControls  col-xs-8 col-sm-8">
                         <input type="file" class="input-text" name="upload_file" id="upload_file">
                     </div>
                     <div class="col-3"> </div>
@@ -132,7 +133,7 @@
                 <div class="row cl" style="margin-top:30px;margin-left:30px;">
                     <div class="col-xs-6 col-sm-5 col-xs-offset-2 col-sm-offset-2">
                         <input class="btn btn-primary radius" type="button" value="&nbsp;确&nbsp;定&nbsp;"
-                            onCLick="uploadImg()">
+                            onCLick="uploadLocalImg();">
                         <input class="btn btn-default radius" type="button" value="&nbsp;取&nbsp;消&nbsp;"
                             onClick="layer_close();">
                     </div>
@@ -141,8 +142,51 @@
         </div>
         <!-- 本地上传end -->
     </div>
+    <!-- 网络图片 -->
     <div class="tabCon">
-
+        <form id="form-uploadurlimg" method="post" action="" enctype="multipart/form-data">
+            <div class="row cl" style="margin-top:20px;">
+                <label class="form-label col-xs-2 col-sm-2"><span class="c-red">*</span>图片要求: </label>
+                <div class="formControls col-xs-8 col-sm-8">
+                    格式 jpg,png,gif,jpeg,webp; 大小不超过4M.
+                </div>
+                <div class="col-3"> </div>
+            </div>
+            <div class="row cl" style="margin-top:20px;">
+                <label class="form-label col-xs-2 col-sm-2">
+                    <span class="c-red">*</span>图片地址:</label>
+                <div class="formControls col-xs-8 col-sm-8">
+                    <input type="text" class="input-text" name="url_file" id="url_file">
+                </div>
+                <div class="col-3"> </div>
+            </div>
+            <div class="row cl" style="margin-top:20px;">
+                <input type="hidden" name="img_id" value={$img_id}>
+                <div class="formControls col-xs-12 col-sm-8">
+                    <div class="skin-minimal">
+                        <div class="check-box">
+                            <input type="checkbox" name="thumb" value="{$thumb}" {$thumb ? 'checked' : "" }>
+                            <label for="thumb-1">缩略图</label>
+                            <input type="text" class="input-text" name="width" value={$width} style="width: 80px;">缩略图宽度
+                            <input type="text" class="input-text" name="height" value={$height}
+                            style="width: 80px;">缩略图高度
+                        </div>
+                        <div class="check-box">
+                            <input type="checkbox" name="original" value="{$original}" {$original ? 'checked' : "" }>
+                            <label for="overwrite">保留原图</label>
+                        </div>
+                    </div>
+                </div>
+            </div>
+            <div class="row cl" style="margin-top:30px;margin-left:30px;">
+                <div class="col-xs-6 col-sm-5 col-xs-offset-2 col-sm-offset-2">
+                    <input class="btn btn-primary radius" type="button" value="&nbsp;确&nbsp;定&nbsp;"
+                        onCLick="uploadUrlImg()">
+                    <input class="btn btn-default radius" type="button" value="&nbsp;取&nbsp;消&nbsp;"
+                        onClick="layer_close();">
+                </div>
+            </div>
+        </form>
     </div>
     <!-- 在线图片 -->
     <div class="tabCon">
@@ -183,7 +227,8 @@
     });
 
     //step1本地上传图片
-    function uploadImg() {
+    function uploadLocalImg() {
+        var layer = $("#layer").val();
         if ($("#upload_file").val() == '') {
             layer.msg("请选择要上传的文件", {
                 icon: 6,
@@ -207,17 +252,22 @@
                 success: function (res) {
                     if (res.code == 0) {
                         // layer.close(loadIndex);
-                        console.log(res);
-                        var img = res.picture_url + res.picname;
-                        window.parent.$("#" + res.img_id).val(img);
+                        if (layer == true) {
+                            var img = res.thumb ? res.thumb : res.picname;
+                            
+                            window.parent.$("#" + res.img_id).val(img);
 
-                        if (res.thumbname) {
-                            img = res.picture_url + res.thumbname;
-                            window.parent.$("#thumb").val(img);
+                            window.parent.$("#view-" + res.img_id).attr('src', img);
+                            
+                            layer_close();
+                        } else {
+                            layer.msg('上传成功', {
+                                icon: 1,
+                                time: 1000
+                            },()=>{
+                                window.location.reload();
+                            });
                         }
-
-                        window.parent.$("#view-" + res.img_id).attr('src', img);
-                        layer_close();
                     } else {
                         // layer.close(loadIndex);
                         layer.msg(res.msg, {
@@ -231,35 +281,9 @@
         }
     }
 
-
-
-    function onlinepicture(page) {
-        var data = { "page": page };
-        $.ajax({
-            url: '{:url("file_manager/onlineimg")}',
-            type: 'GET',
-            async: true,
-            cache: false,
-            data: 'page=' + page,
-            processData: false,
-            contentType: false,
-            dataType: "json",
-            success: function (res) {
-                if (res.code == 0) {
-                    html_str = "";
-                    res.list.forEach(element => {
-                        html_str += '<li><img width="170" height="113" src="' + element.url + '?noCache=' + element.mtime + '"';
-                        html_str += '_src="' + element.url + '">';
-                        html_str += '<span class="icon"></span></li>';
-                    });
-                    $('ul.list').prepend(html_str);
-                }
-            }
-        });
-    }
-
     // 网络图片
     function uploadUrlImg() {
+        var layer = $("#layer").val();
         if ($("#url_file").val() == '') {
             layer.msg("文件地址不可以为空", {
                 icon: 6,
@@ -269,7 +293,7 @@
         } else {
             var formData = new FormData($("#form-uploadurlimg")[0]);
             $.ajax({
-                url: '{:url("file_manager/uploadurlimg")}',
+                url: '{:url("file_manager/uploadUrlImg")}',
                 type: 'POST',
                 async: true,
                 cache: false,
@@ -282,18 +306,22 @@
                 },
                 success: function (res) {
                     if (res.code == 0) {
-                        console.log(res);
+                        console.log(layer);
                         // layer.close(loadIndex);
-                        var img = res.picture_url + res.picname;
-                        window.parent.$("#" + res.img_id).val(img);
-
-                        if (res.thumbname) {
-                            img = res.picture_url + res.thumbname;
-                            window.parent.$("#thumb").val(img);
+                        if (layer == true) {
+                            var img = res.picname;
+                            window.parent.$("#" + res.img_id).val(img);
+    
+                            if (res.thumbname) {
+                                img = res.thumbname;
+                                window.parent.$("#thumb").val(img);
+                            }
+    
+                            window.parent.$("#view-" + res.img_id).attr('src', img);
+                            layer_close();
+                        } else {
+                            window.location.reload();
                         }
-
-                        window.parent.$("#view-" + res.img_id).attr('src', img);
-                        layer_close();
                     } else {
                         // layer.close(loadIndex);
                         layer.msg(res.msg, {
@@ -307,6 +335,33 @@
         }
     }
 
+    function onlinepicture(page) {
+        var data = { "page": page };
+        $.ajax({
+            url: '{:url("file_manager/onlineimg")}',
+            type: 'GET',
+            async: true,
+            cache: false,
+            data: 'page=' + page,
+            processData: false,
+            contentType: false,
+            dataType: "json",
+            success: function (res) {
+                if (res.code == 0) {
+                    html_str = "";
+                    res.list.forEach(element => {
+                        html_str += '<li><img width="170" height="113" src="' + element.url + '?noCache=' + element.mtime + '"';
+                        html_str += '_src="' + element.url + '">';
+                        html_str += '<span class="icon"></span></li>';
+                    });
+                    $('ul.list').prepend(html_str);
+                }
+            }
+        });
+    }
+
+
+
     function uploadOnlineImg() {
         if ($("#online_file").val() == '') {
             layer.msg("文件地址不可以为空", {