使用cffile重命名文件时如何获取文件扩展名

The*_*Man 5 coldfusion

我正在使用cffile标签上传我的文件并使用新名称重新保存.我的问题是该文件可能是几种不同的格式,我不知道如何检测文件扩展名.我正在使用以下代码:

<cfset ui = createUUID()>
<cffile 
  action="upload" 
  accept="video/x-flv, video/mp4, video/x-msvideo"
  destination="e:\www2\uploads\#ui#.#cffile.ServerFileExt#" 
  nameconflict="makeunique" 
  filefield="form.file"
>
Run Code Online (Sandbox Code Playgroud)

它告诉我,cffile是未定义的.

scr*_*ler 12

我建议先上传,然后重命名:

<cfset ui = createUUID()>
<cffile 
  action="upload" 
  accept="video/x-flv, video/mp4, video/x-msvideo" 
  destination="e:\www2\uploads\" 
  nameconflict="makeunique" 
  filefield="form.file"
/>
<cffile 
  action="rename" 
  source="e:\www2\uploads\#cffile.serverFileName#" 
  destination="e:\www2\uploads\#ui#.#cffile.serverFileExt#"
/>
Run Code Online (Sandbox Code Playgroud)