添加删除图片接口
This commit is contained in:
		| @@ -39,13 +39,13 @@ public class ExcelUploadUtil { | ||||
|             String suffix = originalFilename.substring(index); | ||||
|             //uuid生成新的文件名 | ||||
|             String newName = UUID.randomUUID().toString() + suffix; | ||||
| //            File file = new File("/Users/liuchengqian/Desktop/DaJiang/" + subDir); | ||||
|             File file = new File("/home/sxy/server/industrial_measurement/" + subDir); | ||||
|             File file = new File("/Users/liuchengqian/Desktop/DaJiang/" + subDir); | ||||
| //            File file = new File("/home/sxy/server/industrial_measurement/" + subDir); | ||||
|             if (!file.exists()) { | ||||
|                 file.mkdirs(); | ||||
|             } | ||||
| //            String path = "/Users/liuchengqian/Desktop/DaJiang/" + subDir + newName; | ||||
|             String path = "/home/sxy/server/industrial_measurement/" + subDir + newName; | ||||
|             String path = "/Users/liuchengqian/Desktop/DaJiang/" + subDir + newName; | ||||
| //            String path = "/home/sxy/server/industrial_measurement/" + subDir + newName; | ||||
|             //实现上传 | ||||
|             fileInput.transferTo(new File(path)); | ||||
|             return "http://118.24.27.47:2088/" + subDir + newName; | ||||
| @@ -97,28 +97,21 @@ public class ExcelUploadUtil { | ||||
|  | ||||
|     /** | ||||
|      * 删除本地或服务器储存的图片 | ||||
|      * | ||||
|      * @param path | ||||
|      * @return | ||||
|      */ | ||||
|     public static String delFile(String path) { | ||||
|         String resultInfo = null; | ||||
|     public static String delFile(String path, int subDirType) { | ||||
|         String subDir = subDirType == 1 ? "excel/" : "picture/"; | ||||
|         int lastIndexOf = path.lastIndexOf("/"); | ||||
|         String imgPath = path.substring(lastIndexOf + 1, path.length()); | ||||
|         System.out.println(imgPath); | ||||
|         imgPath = "/usr/local/etc/images/" + imgPath; | ||||
| //        img_path = "/usr/etc/images/Folder/" + img_path; | ||||
|         File file = new File(imgPath); | ||||
|         String fileName = path.substring(lastIndexOf + 1); | ||||
|         String filePath = "/Users/liuchengqian/Desktop/DaJiang/" + subDir + fileName; | ||||
| //        String filePath = "/home/sxy/server/industrial_measurement/" + subDir + fileName; | ||||
|         File file = new File(filePath); | ||||
|         if (file.exists()) { | ||||
|             if (file.delete()) { | ||||
|                 resultInfo = "删除成功!"; | ||||
|             } else { | ||||
|                 resultInfo = "删除失败!"; | ||||
|                 return "删除成功!"; | ||||
|             } | ||||
|         } else { | ||||
|             resultInfo = "文件不存在"; | ||||
|             return "删除失败!"; | ||||
|         } | ||||
|         return resultInfo; | ||||
|         return "文件不存在"; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|   | ||||
		Reference in New Issue
	
	Block a user