star7th 3 years ago
parent
commit
fe9b8a0308
1 changed files with 13 additions and 6 deletions
  1. 13 6
      server/Application/Api/Controller/AttachmentController.class.php

+ 13 - 6
server/Application/Api/Controller/AttachmentController.class.php

@@ -45,12 +45,19 @@ class AttachmentController extends BaseController {
 
         $array = explode("/Public/Uploads/", $url) ;
         $file_path = "../Public/Uploads/".$array[1] ;
-	$oss_open = D("Options")->get("oss_open" ) ;
-	if (!$oss_open && file_exists($file_path) && $ret['display_name']) {
-    	    $this->_downloadFile($file_path, $ret['display_name']);
-	}else{
-            header("location:{$url}");
-        }
+        $oss_open = D("Options")->get("oss_open" ) ;
+        if (!$oss_open 
+            && file_exists($file_path)
+            && $ret['display_name']
+            && !strstr(strtolower($file_path),'.bmp')
+            && !strstr(strtolower($file_path),'.jpg')
+            && !strstr(strtolower($file_path),'.png')
+            && !strstr(strtolower($file_path),'.pdf')
+         ) {
+                $this->_downloadFile($file_path, $ret['display_name']);
+        }else{
+                header("location:{$url}");
+            }
         
       }else{
         echo "www.showdoc.cc";