On 12/11/07, Les Mizzell <[EMAIL PROTECTED]> wrote:
>
> Is there a good/safe way to use cffile to upload a file out to the
> server and rename it at the same time? Only problem is, the file type is
> usually unknown - could be a Word doc, rtf, pdf, xls ....
>
> Folks are wanting to use some really weird file names at times and I'd
> like to rename everything to simply match a previously existing ID.
>
> Here's a real file name someone tried to use:
>
> 2006 CBF TRIP (for Travel ins) and Marco revised as of Apr 19 _June
> 30th-revised.xls
>
> Yea, right....
>
> Id rather force that to the record ID and date like
> Rec1234-20061224.xls
I'm taking for granted here you already have the record ID...This just
covers changing the file name after the ID was recorded. you might actually
need to go back and update that row with the new file name we are setting as
CleanFileName.
<cffile
action="upload"
fileField="FORM.FileName#i#"
destination="#ExpandPath("/directory/")#"
nameConflict="MakeUnique"
mode="777">
<cfset CleanFileName = "#RecordID#-#TheDate#.#cffile.ClientFileExt#">
<cffile action="rename"
source="#ExpandPath("/directory/")##ServerFile#"
destination="#ExpandPath("/directory/")##CleanFileName #"
nameconflict="overwrite">
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
ColdFusion 8 - Build next generation apps
today, with easy PDF and Ajax features - download now
http://download.macromedia.com/pub/labs/coldfusion/cf8_beta_whatsnew_052907.pdf
Archive:
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:294566
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4