• Horn Player – Computer Dude – Gig Pig …
  • Home
  • About
  • Blog
  • Services
  • Contact
  • Webmail
  • Terms

Robert A. Owen - Musician - Technology Leader

Music, Technology, Rants and Funnies - Randomness at its best!

  • Blog
  • Internet
    • IIS 6
    • IIS 7.5
    • Javascript
    • Web Design
      • WordPress
      • Coldfusion
  • Support
    • MicroSoft
      • Powershell
      • Surface
      • Windows10
      • Zune
    • PC-Care
    • Software
    • Virus
      • Email Scam
    • Vista Quest
    • Windows 7
  • Pictures
    • Instagram
  • Music
  • Friday Funnies
  • General
    • CoWorking
    • Gadgets
    • Politico
    • Random – TidBit
    • Rant
    • Review
    • Site of the Week
    • Useless
    • Xbox
      • Games
You are here: Home / Coldfusion / Upload Files with Coldfusion.. It’s Simple!!

Upload Files with Coldfusion.. It’s Simple!!

February 7, 2007 By Robert Owen

This is simple… simple I say!!! Uploading files to your website using Coldfusion is actually a Simple process… There is nothing really secret or sinister about this so.. here we go:
First we need a form. See… Simple!!! Everyone can do a form. Lets say we are letting people upload an image to the site:

<code>

<form name=”uploadImage” action=”uploadimage.cfm” method=”post” enctype=”multipart/form-data”>

<h2>Upload your image</h2>

<table width=”80%”>
<tr>
<td>Upload your image</td>
<td><input name=”image” type=”file”></td>
</tr>
<tr>
<td><input type=”reset” value=”Clear Entry”></td>
<td><input type=”submit” value=”Upload the Image”></td>
</tr>
</table>
</form>
</code>

Now we’ve got our form! Hurrahh!! See, Easy! Now for this form to work the way we want, we need to make sure and make the “enctype” set to “multipart/form-data” Basically this tells the form that it is submitting more than just text.

Check out the <a href=”http://www.w3.org/TR/html4/interact/forms.html#h-17.13.4.2″>W3C </a> for more information on html form use.

Ok. Now that we have our form we need a way to process the information. notice, in the form I set the “action” to “uploadimage.cfm”. That is telling our form.. Ok take this information and send it to this file for processing.

See… Simple…
No our upload form could look something like this:

<code>
<cffile action=”upload” destination=”x:\FakeDirectory\www\images\” nameconflict=”overwrite” filefield=”image”>
</code>

Now… is that it??? Sure thing. This takes the contents of the “filefield” from our upload form and saves it to our Fake directory located on the server. It will also look at the file name, if it already exists it will just overwrite the file with the new version.

Whew!!! See… Simple… Now, this is just a BASIC example of how to upload files…. This will not check what type of file is uploaded or how big it is.. Those are two things that you would want to do before keeping the file on your server.

But this is a start… I’ll give an example soon on how to check for file type and set a max size.

© 2007 – 2009, Robert Owen. All rights reserved.

Related posts:

Default ThumbnailTime to learn CFCs once and for all! Default ThumbnailSimple Pop-up: Fuel Default ThumbnailSimple Contact Form Default ThumbnailColdfusion Countdown

Filed Under: Coldfusion Tagged With: Cffile Action, Coldfusion, Destination X, Enctype, H2, Image Type, Information Notice, Input Name, Input Type, Lt, Multipart Form Data, People Image, Sure Thing, Td, Upload Files, Upload Image, Uploading Files, W3c, Www Images

Robert Owen A Horn Player turned salesman, turned Computer Consultant & Horn Player, Turn Network Engineer & Horn Player, Now Technology leader & Musician.... Well, How about a Horn player who does a lot of other stuff? More about me. FacebookInstagramLinkedInTwitter

To Stay up-to-date on all of my crazy Ramblings, enter your e-mail address below.

You'll be amazed!

Recent Posts…

  • What If? – Gig Edition
  • Feedback – two way street
  • Snow-pocalypse… and Cold
  • Snow-pocalypse 2025 – part 6
  • Snow-pocalypse 2025 – part 5

Recent Comments

  • David Gray on Create a Shortcut to open in your Alternate BrowserTwelve years on, this tip remains useful. Though I…
  • Sue K on Use the Snipping Tool to Capture MenusThanks you so much! I could never figure out how t…
  • aa on Increase IIS File Upload LimitsSuperb Robert..after wasting 2 days..this is perfe…
  • León on Windows 7 error 86Funciono para Windows 7 , también descubrí que la…
  • Nicole Larkin on Use the Snipping Tool to Capture MenusNine years later and your post is still helpful. T…

[footer_backtotop]
Content Copyright © 2025 OWEN CONSULTING · All Rights Reserved · Log in