How to Create a Registration Form with Multiple Image Uploads Using ColdFusion

The ColdFusion language includes tags you can use to allow users to upload multiple image files at once during the registration process. The user can upload multiple avatar images or images that represent her portfolio. You use the cffile tag to represent the upload prompt for the user. The user selects an image from the local desktop and clicks "Submit" to submit and upload the images to your server.

Instructions

    • 1

      Open your Adobe ColdFusion editor and open the project and source code file you want to use to submit the multiple images.

    • 2

      Add the cffile tags for each of the images you want to allow the user to upload. The following code allows the user to upload two images:

      <cffile action="upload" fileField="image" destination="#thisDir#" result="fileUpload"
      nameconflict="overwrite">
      <cffile action="upload" fileField="image" destination="#thisDir#" result="fileUpload"
      nameconflict="overwrite">

      This code shows two buttons with which the user can upload a file. If the file name already exists, the old file is overwritten. The destination is the current directory of the Web page hosting the registration, but you can specify any upload folder for your users.

    • 3

      Create the code that uploads the image after the user clicks the "Submit" button. Add the following to the processing section of your code:

      <cfimage action="read" source="#fileUpload.serverfile#" name="myImage">
      <cffile action="delete" file="#fileUpload.serverDirectory#/#fileUpload.serverFile#">

    • 4

      Save the file and click the "Run" button in the toolbar to execute the new code in the debugger, so you can test it.

Related Searches:

References

Comments

Related Ads

Featured