|
ColdFusion Home
Basic ColdFusionIntroductionColdFusion Installation ColdFusion Editors ColdFusion Syntax ColdFusion Includes ColdFusion Variables ColdFusion Variable Types ColdFusion If Statements ColdFusion Loops ColdFusion Datasource ColdFusion Database Queries ColdFusion Lists ColdFusion Arrays ColdFusion Redirect ColdFusion Debugging ColdFusion Error Handling Advanced ColdFusionColdFusion MailColdFusion Functions ColdFusion Components ColdFusion Web Services ColdFusion Upload File ColdFusion Read File ColdFusion Write File ColdFusion Append File ColdFusion Rename File ColdFusion Copy File ColdFusion Move File ColdFusion Delete File Cffile Parameters Using cffile Parameters ColdFusion FTP (cfftp) cfftp Cached Connections ColdFusion HTTP (cfhttp) ColdFusion Query of Queries ColdFusion Charts ColdFusion Summary ColdFusion AdminCF AdministratorCF Archive and Deploy CF Scheduled Tasks CF Mini Tutorial ColdFusion BooksColdFusion MX BibleMacromedia ColdFusion MX 7 Web Application Construction Kit
$1.99 Domain Names
With every new non-domain purchase thru ZappyHost, you get a domain name for only $1.99. |
ColdFusion Upload FileYou can use ColdFusion's cffile tag to upload a file to the server. To allow users to upload a file to the server, you first need to provide a form for them to specify which file they want to upload. Once they click the submit button of the form, the action page is called. This is the page that needs to contain the cffile tag. Example of Uploading a File to the ServerThe following code creates a form, then if the form has been submitted, uploads the file. By only supplying a directory name for the destination, the original file name will be intact. If we wanted to change it, we could specify another file name. Also note that you need to ensure that you have
Name ConflictsIf there's already a file of the same name, the above code will fail. Fortunately, the cffile tag has an attribute called nameConflict. The nameConflict attribute allows you to determine what to do if there's a file with the same name already on the server. Possible values for the nameConflict attribute are:
Restricting File TypesIf you only want your users to be able to upload certain file types, you can use the accept attribute. This allows you to provide a comma separated list of file types that are allowed to be uploaded. For example, Other AttributesYou can also supply the following (optional) attributes to the cffile tag.
|
Need Website Content?
Get unique, quality digital content for your website.
|