I'm using a cffile
tag to upload my file and resave it with a new name. My issue is that the file could be a few different formats and I don't know how to detect the file extension. I'm using the code below:
<cfset ui = createUUID()>
<cffile
action="upload"
accept="video/x-flv, video/mp4, video/x-msvideo"
destination="e:\www2开发者_StackOverflow社区\uploads\#ui#.#cffile.ServerFileExt#"
nameconflict="makeunique"
filefield="form.file"
>
It's telling me that cffile is undefined.
I recommend uploading first, then renaming:
<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#"
/>
I found this awesome function created by Ryan Stille
It should do everything you need
I used it to get the extension then I just created a file name with a UUID
<cffile action="upload" destination="file://upload_#createUUID()#.#fileExt#" nameconflict="makeunique" result="#formField#">
精彩评论