diff --git a/core/src/main/java/lucee/runtime/functions/system/GetTempFile.java b/core/src/main/java/lucee/runtime/functions/system/GetTempFile.java
index ef7108ed5d..36081ea295 100644
--- a/core/src/main/java/lucee/runtime/functions/system/GetTempFile.java
+++ b/core/src/main/java/lucee/runtime/functions/system/GetTempFile.java
@@ -33,12 +33,18 @@
public final class GetTempFile implements Function {
public static String call(PageContext pc, String strDir, String prefix) throws PageException {
+ return call(pc, strDir, prefix, ".tmp");
+ }
+
+ public static String call(PageContext pc, String strDir, String prefix, String extension) throws PageException {
Resource dir = ResourceUtil.toResourceExisting(pc, strDir);
pc.getConfig().getSecurityManager().checkFileLocation(dir);
if (!dir.isDirectory()) throw new ExpressionException("[" + strDir + "] is not a directory");
int count = 1;
Resource file;
- while ((file = dir.getRealResource(prefix + pc.getId() + count + ".tmp")).exists()) {
+ if (extension.trim().isEmpty() == true) { extension = ".tmp"; }
+ if (extension.charAt(0) != '.') { extension = "." + extension; }
+ while ((file = dir.getRealResource(prefix + pc.getId() + count + extension)).exists()) {
count++;
}
try {
diff --git a/core/src/main/java/resource/fld/core-base.fld b/core/src/main/java/resource/fld/core-base.fld
index 28e132d30d..4b921dd5a6 100755
--- a/core/src/main/java/resource/fld/core-base.fld
+++ b/core/src/main/java/resource/fld/core-base.fld
@@ -6582,6 +6582,14 @@ if this attribute is not provided all types are returned.
Yes
Prefix of a temporary file to create in the dir directory
+
+ extension
+ ext
+ string
+ No
+ tmp
+ Creates temporary files with user defined extension, default is .tmp
+
string