memberlogin
contactus
randomfacts

How to upload files with coldfusion

Uploading a file with coldfusion is extremely easy - all that you need to know is the full path to the folder you want to upload to, the name of the file field that holds the path to the file to upload and voila.

 

 <cffile action="upload"
    filefield="attachment1"
    destination="c:\\inetpub\\wwwroot\\mydomain\\attachments\\"
    nameconflict="Makeunique">
 <!--- now create a temporary holder for the attachment later on --->
 <cfset attachment_local_file_1 = "#file.serverfile#">

 

Thats it - this will upload the file to the directory attachments in my root directory / mydomain and is expecting that the file field name from the previous screen is attachment1 and in case a file with the same name already exists on the server - the file name will be changed as to not overwrite the existing file with the same file name.

So in the end the variable attachment_local_file_1 holds the name of the file after it's uploaded to the server.