瀏覽代碼

fix remove file

causefx 8 年之前
父節點
當前提交
2bfcbe80ef
共有 1 個文件被更改,包括 8 次插入2 次删除
  1. 8 2
      functions.php

+ 8 - 2
functions.php

@@ -1756,8 +1756,14 @@ function uploadAvatar($path, $ext_mask = null) {
 // Remove file
 function removeFiles($path) {
     if(is_file($path)) {
-        writeLog("success", "file was removed");
-        unlink($path);
+	    $fileType = getExtension($path);
+	    if(in_arrayi($fileType, array('jpg','jpeg','png','json','db','gif'))){
+		    writeLog("success", "file was removed");
+		unlink($path);
+	    } else{
+		 writeLog("error", "file was not removed");
+		 echo json_encode('Invalid File Type');   
+	    }
     } else {
   		writeLog("error", "file was not removed");
 		echo json_encode('No file specified for removal!');