当我使用上面的代码时,刷新图像后默认删除。 我的目标是在单击“删除”按钮后,它应该删除并要求另一个文件上传该特定的passportImage 这是我的代码
String fileName = "D:\\WEBSITE_FILES\\docs\\OTR\\" + db_unicid + "\\passportImage.jpg";
java.io.File f = new java.io.File(fileName);
if (f.exists()) {
f.delete();
out.println("File found");
} else {
out.println("File Not Found!");
}
String pathimage = "D:\\WEBSITE_FILES\\docs\\OTR\\" + db_unicid + "\\passportImage.jpg";
File fileimage = new File(pathimage);
boolean existsimage = fileimage.exists();
if (!existsimage) {
out.println("<input type='file' name='passportImage' id='passportImage' onblur='valFileExt(this.id);' size='50' ><td><input type='submit' value='Upload '/>File not Available");
} else {
// It returns true if File or directory exists
out.println("<a href='/WEBSITE_FILES/Incois_docs/OTR/" + db_unicid + "/passportImage.jpg' target='blank'> View Image</a></td> td><input type='submit' id='btnSubmit' name='btnSubmit' value='delete'/></td>");
}