Adobe
Products

Top destinations

  • Adobe Creative Cloud
  • Creative Suite
  • Adobe Marketing Cloud
  • Acrobat
  • Photoshop
  • SiteCatalyst
  • Students
  • Elements family

Adobe Creative Cloud

  • What is Adobe Creative Cloud?
  • Design
  • Web
  • Photography
  • Video
  • Students
  • Teams
  • Enterprise
  • Educational institutions

Design and photography

  • Photoshop
  • Illustrator
  • InDesign
  • Adobe Muse
  • Lightroom

Video

  • Adobe Premiere
  • After Effects

Web development and HTML5

  • Edge Tools & Services [opens in a new window]
  • Dreamweaver
  • Gaming [opens in a new window]

Adobe Marketing Cloud

  • What is Adobe Marketing Cloud?
  • Digital analytics
  • Social marketing
  • Web experience management
  • Testing and targeting
  • Media optimization

Analytics

  • SiteCatalyst
  • Adobe Discover
  • Insight

Social

  • Adobe Social

Experience Manager

  • CQ
  • Scene7

Target

  • Test&Target
  • Recommendations
  • Search&Promote

Media Optimizer

  • AdLens
  • AudienceManager
  • AudienceResearch

Document services

  • Acrobat
  • EchoSign [opens in a new window]
  • FormsCentral [opens in a new window]
  • SendNow [opens in a new window]
  • Acrobat.com [opens in a new window]

Publishing

  • Digital Publishing Suite

  • See all products
Business solutions

By business need

  • Digital analytics
  • Digital publishing
  • Document management
  • Media optimization
  • Social marketing
  • Testing and targeting
  • Video editing and serving
  • Web development [opens in a new window]
  • Web experience management
  • See all business needs

By industry

  • Broadcast
  • Education
  • Financial services
  • Government
  • Publishing
  • Retail
  • See all industries
Support & Learning

I need help

  • Products
  • Adobe Creative Cloud
  • Adobe Marketing Cloud
  • Forums [opens in a new window]

I want to learn

  • Training and tutorials
  • Certification [opens in a new window]
  • Adobe Developer Connection
  • Adobe Design Center
  • Adobe TV [opens in a new window]
  • Adobe Marketing Center
  • Adobe Labs [opens in a new window]
Download
  • Product trials
  • Adobe Flash Player
  • Adobe Reader
  • Adobe AIR
  • See all downloads
Company
  • Careers at Adobe
  • Investor Relations
  • Newsroom
  • Privacy
  • Corporate Social Responsibility
  • Customer Showcase
  • Contact us
  • More company info
Buy
  • For personal and professional use
  • For students, educators, and staff
  • For small and medium businesses
  • Volume Licensing
  • Special offers
  • Adobe Marketing Cloud sales [opens in a new window]
Search
 
Info Sign in
Why sign in? Sign in to manage your account and access trial downloads, product extensions, community areas, and more.
Welcome,
My Adobe
My orders
My information
My preferences
My products and services
Sign out
My cart
Privacy My Adobe
Adobe
Products Sections Buy   Search  
Solutions Company
Help Learning
Sign in Sign out Privacy My Adobe
Preorder Estimated Availability Date. Your credit card will not be charged until the product is shipped. Estimated availability date is subject to change. Preorder Estimated Availability Date. Your credit card will not be charged until the product is ready to download. Estimated availability date is subject to change.
Qty:
Purchase requires verification of academic eligibility
Subtotal
Promotions
Estimated shipping
Tax
Calculated at checkout
Total
Review and Checkout
Adobe Developer Connection / Dreamweaver Developer Center /

Creating a ColdFusion upload page in Dreamweaver CS4

by Raymond Camden

Raymond Camden
  • raymondcamden.com

Created

12 December 2008

Page tools

Share on Facebook
Share on Twitter
Share on LinkedIn
Bookmark
Print
client-serverColdFusion 8Dreamweaver CS4dynamic websiteextensibilityfile management
Was this helpful?
Yes   No

By clicking Submit, you accept the Adobe Terms of Use.

 
Thanks for your feedback.

Requirements

Prerequisite knowledge

Familiarity with Dreamweaver and ColdFusion.

User level

Intermediate

Required products

  • Dreamweaver (Download trial)
  • ColdFusion (Download trial)

File upload pages allow users to select files from their local hard drive and upload them to a server through a web browser. Building a file upload page with ColdFusion is quick and easy using the upload action of the CFFILE tag. CFFILE is a ColdFusion tag that can perform a variety of file management–related actions such as reading, writing, moving, renaming, and uploading files.

For the purpose of this article, I will focus on the upload action of this tag and provide Dreamweaver CS4 instructions for creating a simple ColdFusion file upload page. Although the step-by-step instructions provided in this article pertain to the Dreamweaver interface, the resulting code, which is listed at the bottom of this page, can be customized for use in other editors as well. The ColdFusion code used in the file upload example will work with versions 5 and above of ColdFusion Server.

Note: Adobe Dreamweaver Exchange lists the latest extensions available for download. In addition to the method provided in this article, you may also want to visit the Exchange to search for related extensions.

Protecting server security

Allowing file uploads can potentially compromise server security. For this reason, it is a good idea to evaluate possible risks before implementing file uploads in a web application. There is no foolproof way to ensure a secure file upload in a web application, although through careful design, it is possible to reduce your risk.

Some suggestions for protecting server security:

  • Carefully choose the directory to which the files are to be uploaded. Files should be uploaded to a location on the server that will not conflict with existing application or system files.
  • Restrict upload for file extensions that can potentially be dangerous: .cfml, .cfm, .php, .bat, .exe and so on.
  • Authenticate users before allowing them to upload files.

Note: For additional information about server security, refer to Security Best Practice: Evaluating the Risks of Allowing Uploading and of Attached Files on Your Server (TechNote 17618).

Building the HTML form

The following steps provide instructions on how to create the HTML form. This simple HTML form will be the interface through which users select and upload files.

  1. Create a new ColdFusion document and save it within a defined site that has been configured to handle ColdFusion content. Name this page cf_upload.cfm and change the title from Untitled Document to Upload File with ColdFusion.

    Note: For more information about defining a site, refer to Setting up a site in Dreamweaver CS4 / Setting up a site in Dreamweaver CS5 in Dreamweaver Help.

  2. Select Insert > Form or drag a form button onto the page by clicking and dragging the Form icon in the Forms tab of the Insert bar.
  3. Select the form using the tag selector or by clicking the red dashed line. If you do not see the red dashed line turn on the Invisible Elements (View > Visual Aids > Invisible Elements).
    • In the Property inspector of the form, enter upload_form in the Form Name field.
    • In the Action field, enter cf_upload.cfm.
    • Switch the method from Get to Post.
    • In the Enctype field, select multipart/form-data.
    • Change to code view (View > Code), the code should now look like the example below:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Upload File with ColdFusion</title> </head> <body> <form action="cf_upload.cfm" method="post" enctype="multipart/form-data" name="upload_form"></form> </body> </html>
  1. Create an insertion point within the form by clicking inside the red dashed line and choose Insert > Form Objects > File Field. It's also possible to add form objects to the page by dragging them from the Forms tab of the Insert bar. Just click and drag the form object to the desired location within the form tag.
  2. Select the file field you just inserted and enter ul_path in the File Field Name of the Property inspector.
  3. Add a button form object to the page using one of the methods described in Step 4.
  4. Select the button and enter upload_now in the Button Name field of the Property inspector. Set the Action property to Submit form.

Here is the completed HTML form code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Upload File with ColdFusion</title> </head> <body> <form action="cf_upload.cfm" method="post" enctype="multipart/form-data" name="upload_form"> <input type="file" name="ul_path" id="ul_path" /><input name="upload_now" type="submit" value="Submit" /> </form> </body> </html>

Adding the ColdFusion file upload functionality

Now that the HTML form is ready to go, you can add a few lines of CFML code using the Dreamweaver interface:

  1. Choose Code view using the View menu (View > Code) or by clicking the Code icon in the document toolbar.
  2. Place your cursor after the <body> tag and press Enter once to create a blank space.
  3. Select the CFML Flow tab of the Insert bar and click the cfif button to insert the CFIF tag.
  4. In the Code view pane click before the final bracket of the opening CFIF tag and enter:
isdefined("form.upload_now")

Your CFIF tag should now match the code below:

<cfif isdefined("form.upload_now")></cfif>
  1. Click between the opening and closing CFIF tags and press Enter twice to create a blank line. With your cursor at the beginning of this new line, click the CFFILE icon in the CFML Advanced tab of the Insert bar.
  2. In the Cffile dialog box, enter the following values (see Figure 1):
    • Action: Choose Upload from the Action list menu.
    • File Field: Enter the name of the File Field form object ul_path.
    • Destination Path: Enter the absolute path to the directory in which the files will be uploaded. The path you enter depends on the location of the directory in which the files will be saved on the server.

    Note: On Unix systems, make sure that the upload path directory is configured with the correct permissions so file upload can write to that directory. Normally, this directory would be owned by the ColdFusion user or the account that runs the web server.

    Note: On Mac OS X systems, if you end up with a path with colons (:) in it—for example, Macintosh HD:Users:ray:Documents:Web Sites:webroot:cfuploaddwarticle—replace colons with forward slashes: /Users/ray/Documents/Web Sites/webroot/cfuploaddwarticle.

    • Accept Files: List the mime types and file types that you will accept separated by commas. For this example, only GIF and JPG image files will be accepted, so enter: image/gif,image/jpeg.
    • Filename Resolution: The option selected in this field determines what will happen if the name of the file to be uploaded already exists on the server. All available options are listed below:
      • Error: The file will not be uploaded and ColdFusion will stop processing the page and return an error.
      • Skip: The file is not uploaded and no error message is displayed.
      • Overwrite: Files with the same name are overwritten.
      • Makeunique: The file is uploaded and given a unique name. In this example, Makeunique is chosen for Filename Resolution.
The Tag Editor - cffile dialog box, with values filled in.
Figure 1. The Tag Editor - cffile dialog box, with values filled in.
  1. After completing this dialog box, click OK.
  2. Between the closing bracket of the CFFILE tag and closing CFIF tag, type in a message to be displayed when a file has been uploaded. For example:
<cfif isdefined("form.upload_now")> <cffile accept="image/gif,image/jpg,image/jpeg" action="upload" destination="/Users/ray/Documents/Web Sites/webroot/cfuploaddwarticle" filefield="ul_path" nameconflict="makeunique"> Thanks for uploading a file! </cfif>

The complete code is listed below:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Upload File with ColdFusion</title> </head> <body> <cfif isdefined("form.upload_now")> <cffile accept="image/gif,image/jpg,image/jpeg" action="upload" destination="/Users/ray/Documents/WebSites/webroot/cfuploaddwarticle" filefield="ul_path" nameconflict="makeunique"> Thanks for uploading a file! </cfif> <form action="cf_upload.cfm" method="post" enctype="multipart/form-data" name="upload_form"> <input type="file" name="ul_path" id="ul_path" /> <input name="upload_now" type="submit" value="Submit" /> </form> </body> </html>

Creative Commons License
This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License

More Like This

  • Creating a Spry XML data set
  • Which server-side technology should I choose?
  • Exchanging data using the Spry framework for Ajax and PHP
  • Managing multiple subscriptions in PHP
  • Creating and consuming ColdFusion components and web services with Dreamweaver CS4
  • Creating custom server behaviors and Dreamweaver extensions
  • Creating user-defined functions for ColdFusion 8 in Dreamweaver CS4
  • Building your first dynamic website – Part 1: Setting up the site and database
  • XSL overview
  • Creating master and detail ColdFusion pages

Tutorials and samples

Tutorials

  • Working with updated responsive layout features in the Dreamweaver CS6 update
  • Creating your first website – Part 3
  • Creating your first website – Part 2
  • Creating your first website – Part 5

Samples

  • Responsive design with jQuery marquee
  • Customizable starter design for jQuery Mobile
  • Customizable starter design for HTML5 video
  • Customizable starter design for multiscreen development

Products

  • Adobe Creative Cloud
  • Creative Suite
  • Adobe Marketing Cloud
  • Acrobat
  • Photoshop
  • Digital Publishing Suite
  • Elements family
  • SiteCatalyst
  • For education

Download

  • Product trials
  • Adobe Reader
  • Adobe Flash Player
  • Adobe AIR

Support & Learning

  • Product help
  • Forums

Buy

  • For personal and professional use
  • For students, educators, and staff
  • For small and medium businesses
  • Volume Licensing
  • Special offers

Company

  • News room
  • Partner programs
  • Corporate social responsibility
  • Career opportunities
  • Investor Relations
  • Events
  • Legal
  • Security
  • Contact Adobe
Choose your region United States (Change)
Choose your region Close

North America

Europe, Middle East and Africa

Asia Pacific

  • Canada - English
  • Canada - Français
  • Latinoamérica
  • México
  • United States

South America

  • Brasil
  • Africa - English
  • Österreich - Deutsch
  • Belgium - English
  • Belgique - Français
  • België - Nederlands
  • България
  • Hrvatska
  • Česká republika
  • Danmark
  • Eastern Europe - English
  • Eesti
  • Suomi
  • France
  • Deutschland
  • Magyarország
  • Ireland
  • Israel - English
  • ישראל - עברית
  • Italia
  • Latvija
  • Lietuva
  • Luxembourg - Deutsch
  • Luxembourg - English
  • Luxembourg - Français
  • الشرق الأوسط وشمال أفريقيا - اللغة العربية
  • Middle East and North Africa - English
  • Moyen-Orient et Afrique du Nord - Français
  • Nederland
  • Norge
  • Polska
  • Portugal
  • România
  • Россия
  • Srbija
  • Slovensko
  • Slovenija
  • España
  • Sverige
  • Schweiz - Deutsch
  • Suisse - Français
  • Svizzera - Italiano
  • Türkiye
  • Україна
  • United Kingdom
  • Australia
  • 中国
  • 中國香港特別行政區
  • Hong Kong S.A.R. of China
  • India - English
  • 日本
  • 한국
  • New Zealand
  • 台灣

Southeast Asia

  • Includes Indonesia, Malaysia, Philippines, Singapore, Thailand, and Vietnam - English

Copyright © 2013 Adobe Systems Incorporated. All rights reserved.

Terms of Use | Privacy | Cookies

Ad Choices

Reviewed by TRUSTe: site privacy statement