Browse Source

文件下载

linwu 1 year ago
parent
commit
7255271af0
2 changed files with 11 additions and 1 deletions
  1. 10 0
      app/mobile/controller/Download.php
  2. 1 1
      app/mobile/view/download/index.html

+ 10 - 0
app/mobile/controller/Download.php

@@ -10,4 +10,14 @@ class Download extends MobileBaseController
     {
         return view();
     }
+
+    public function down()
+    {
+        $file_url = input('file_url', '');
+        $file_path = public_path('static/mobile/download').$file_url;
+        if (!file_exists($file_path)) {
+            jump('文件不存在或已过期!');
+        }
+        return download($file_path,$file_url);
+    }
 }

+ 1 - 1
app/mobile/view/download/index.html

@@ -25,7 +25,7 @@
         let base = {};
 
         base.toUrl = (url) => {
-            location.href = '/static/mobile/download/' + url;
+            location.href = "{:url('down')}?file_url=" + url;
         };
 
         return base;