huangdong 6 年之前
父节点
当前提交
ca742f6cd8
共有 2 个文件被更改,包括 6 次插入4 次删除
  1. 2 1
      mobile/templates/default/talk/school_certs.php
  2. 4 3
      upfile.php

+ 2 - 1
mobile/templates/default/talk/school_certs.php

@@ -319,9 +319,10 @@
                     } else {
                         $.hideLoading();
                         var cimage = res.datas.file_path;
+                        var upload_bg = res.datas.file_site_path;
                         console.log(cimage);
                         if (cimage) {
-                            $(".uploader_bg").css("background-image","url("+cimage+")");
+                            $(".uploader_bg").css("background-image","url("+upload_bg+")");
                             $("input[name='file_path']").val(cimage);
                         } else {
                             $.alert("网络错误");

+ 4 - 3
upfile.php

@@ -50,7 +50,7 @@ function create_uuid($prefix = "") {
 if ($_POST)
 {
     $base_path = BASE_ROOT_PATH . '/data/upload/upfile';
-    $base_site_path = BASE_SITE_URL . '/data/upload/upfile';
+    $base_site_path = '/data/upload/upfile';
     $ret = array();
 
     if ($_FILES["file"]["error"] > 0) {
@@ -60,11 +60,12 @@ if ($_POST)
     {
         $fn = $_FILES["file"]["name"];
         $ext_name = '.' . strtolower(pathinfo($fn)['extension']);
-        $dest_file = $base_path . '/' . date("YmdHis") . '-' . create_uuid() . $ext_name;
+        $filename = date("YmdHis") . '-' . create_uuid() . $ext_name;
+        $dest_file = $base_path . '/' . $filename;
         $result = move_uploaded_file($_FILES["file"]["tmp_name"],$dest_file);
         if ($result) {
             $ret['file_path'] = $dest_file;
-            $ret['file_site_path'] = $base_site_path;
+            $ret['file_site_path'] = $base_site_path .'/' . $filename;
             upfile_joutput_data($ret);
         } else {
             upfile_joutput_error();