HostIssues Community Forums  
Go Back   HostIssues Community Forums > Hosting, Design & Development > Design & Development > Scripts & Tutorials

Notices

Scripts & Tutorials The official AeonCube products and other scripts, code snippets and tutorials.

Reply
 
Thread Tools
  #1  
Old January 24th, 2008, 05:29 PM
j-lucas j-lucas is offline
AeonCube Administrator
 
Join Date: Aug 2006
Location: United Kingdom
Posts: 1,364
ColdFusion Upload

Uploading files in Coldfusion is very easy and we are going to go through the code required for it.

First off create a folder in your directory, in our case we have called it 'files' but it can be anything.

upload.cfm
Code:
<cfset uploadPath = left(getDirectoryFromPath(GetBaseTemplatePath()),len(getDirectoryFromPath(GetBaseTemplatePath()))) & '/files/' >
The above code needs to go at the top of the upload.cfm page above the 'DOCTYPE' / <HEAD> tags. This code just files the directory for uploading so we want files and show above as: '/files/'

upload.cfm
Code:
<form enctype="multipart/form-data" method="post">
 <input type="file" name="fileupload" /><br />
 <input type="submit" value="Upload it" />
</form>
Above is the required code for your form and can be placed any where on your page, BUT the code below is best to go above this code when you get to it.

upload.cfm
Code:
<cfif isDefined("fileupload")>

<cffile action="upload"
    filefield="fileupload"
    nameconflict="overwrite"
    destination= "#uploadPath#" >

<cfoutput>    
<p>Upload Complete!</p>
     File size: #file.FileSize#<br />
     File extension: #CFFILE.ServerFileExt#<br />
     File name: #file.SERVERFILE#<br />
     File location: #file.ServerDirectory#
</cfoutput>
</cfif>
The above code will upload any file to the 'files' folder, it will then show the file information such as file size, file extension, file name and the location.

If the attached Zip file which you can download and view the source code as some gif's in the files folder just in case you dont have any to play with

Have fun uploading!
Attached Files
File Type: zip cf_upload.zip (11.2 KB, 10 views)
__________________
HostMediaUK : Low Cost Hosting | Linux PHP Hosting | Windows ColdFusion Hosting | ASP Hosting | Reseller Hosting | Dedicated Servers
AeonCube Networks : Web Design, ColdFusion Development and Web Hosting
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


All times are GMT. The time now is 06:10 AM.


Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
© 2001-2009 AeonCube Networks A Registered UK Trading Company Skin design and concept by Attitude