public String addFood(){
if (fileName.endsWith(".png") || fileName.endsWith(".jpg")
|| fileName.endsWith(".gif")) {
int num1 = (int) (Math.random() * 10);
int num2 = (int) (Math.random() * 10);
int num3 = (int) (Math.random() * 10);
int num4 = (int) (Math.random() * 10);
int num5 = (int) (Math.random() * 10);
String random = num1 + "" + num2 + "" + num3 + "" + num4 + ""
+ num5;
String path = "C:/Users/asf/Desktop/test/test/WebRoot/upload/" + random + fileName;
File file = new File(path);
try {
FileUtils.copyFile(files, file);
} catch (IOException e) {
e.printStackTrace();
}
s.setRestaurant(rs.getRestaurant(rid));
s.setFoodtype(fts.getFoodtype(ftid));
s.setFoodpic(random + fileName);
fs.addFood(s);
return "success";
}
return "error";
}
if (fileName.endsWith(".png") || fileName.endsWith(".jpg")
|| fileName.endsWith(".gif")) {
int num1 = (int) (Math.random() * 10);
int num2 = (int) (Math.random() * 10);
int num3 = (int) (Math.random() * 10);
int num4 = (int) (Math.random() * 10);
int num5 = (int) (Math.random() * 10);
String random = num1 + "" + num2 + "" + num3 + "" + num4 + ""
+ num5;
String path = "C:/Users/asf/Desktop/test/test/WebRoot/upload/" + random + fileName;
File file = new File(path);
try {
FileUtils.copyFile(files, file);
} catch (IOException e) {
e.printStackTrace();
}
s.setRestaurant(rs.getRestaurant(rid));
s.setFoodtype(fts.getFoodtype(ftid));
s.setFoodpic(random + fileName);
fs.addFood(s);
return "success";
}
return "error";
}