diff --git a/java/org/apache/tomcat/util/http/fileupload/disk/DiskFileItem.java b/java/org/apache/tomcat/util/http/fileupload/disk/DiskFileItem.java index 38c783e15713..3992162470a8 100644 --- a/java/org/apache/tomcat/util/http/fileupload/disk/DiskFileItem.java +++ b/java/org/apache/tomcat/util/http/fileupload/disk/DiskFileItem.java @@ -392,7 +392,10 @@ public void write(File file) throws Exception { * desired file. */ if (file.exists()) { - file.delete(); + if (!file.delete()) { + throw new FileUploadException( + "Cannot write uploaded file to disk!"); + } } if (!outputFile.renameTo(file)) { BufferedInputStream in = null;