Cffile upload  in coldfusion 8

Posted on 2009-04-23
Last Modified: 2013-12-20
I am attempting to upload a file I use CF8. It was working fine and has suddenly stopped working. Is there another way to do it?
<form  action="FileUpload.cfm" enctype="multipart/form-data" method="post">

                          <p align="center"><font size="2">Upload Photo</font><font size="1">

                            <input type="file" name="myfile" />

                            <select name="PictureType" id="PictureType">

                              <option value="A" selected="selected">Select Photo 


                              <option value="A">Condo Exterior</option>

                              <option value="B">Condo Living Room</option>

                              <option value="C">Balcony</option>

                              <option value="D">Condo View</option>

                              <option value="E">bedroom </option>

                              <option value="F">Bathroom</option>

                              <option value="G">Kitchen</option>

                              <option value="H">Other View</option>

                              <option value="I">Other</option>


                           <input name="picturedescription" type="hidden" id="picturedescription" value="">


                            <input name="password" type="text" id="password" size="12">

                            <input name="listingid" type="hidden" id="listingid" value="<cfoutput>#listingid#</cfoutput>" />

 <input name = "Submit" type = "Submit" id="Submit" value="Upload">

                            </font> </span> </p>


<!----Action script that  uploads from form submit --->

<cffile action="upload" filefield="Myfile"

destination="C:\Websites\CSR\\pictures\#form.listingid#\"  nameconflict="overwrite" accept="image/*" >

<!--- If there is an error catch it --->

<cfcatch type="any"><br />

Please upload a file with only these extentions: (.gif) (jpeg) (.jpg)  (.png)  (.psd) (.bmp)<br />

Click Back button to try again. 



<cfif isdefined ("cffile.serverfile")>

<cfset PictureURL = "#cffile.serverfile#">

<cfset  ListingID = "#form.listingid# ">

<cfset PictureType = "#form.pictureType#">

<cfset PictureDescription = "#form.pictureDescription#">


	<cfquery datasource="dsn" name ="addit">

	Insert into table (ListingID,PictureURL, PictureType,PictureDescription)

	Values (#ListingID#,'#PictureURL#','#PictureType#','#PictureDescription#')


<cfcatch type="any">

Table Update Failed




Your Photo #PictureURL#, was uploaded.



<br />

Upload failed


Open in new window

Question by:LeadCo
    LVL 27

    Assisted Solution

    >> has suddenly stopped working

    it'll help a lot if you elaborated on the above more:
    what makes you think it has stopped working?
    what exactly happens now?
    any cf errors you see?
    anything you see in cf logs?

    + anything you have changed recently in your code/server config that might have influenced file upload functionality?

    + is the missing <cftry> tag before your <cffile> tag just a bad copy-paste or are you really missing it?

    + (not that it's related to the problem in any way) you have a closing </span> tag in your code without any opening tag.


    Accepted Solution

    It seems I was not creating the directory prior to trying to upload it. Here is how I fixed it.

    <cfdirectory action="create" directory="C:\Websites\CSR\\pictures\#LIST.ID#">

    This created the directory that my upload goes in, it was failing beacause the directory did not exist.

    Thanks and God Bless you for trying to help me  this worked so no more issues hopefully.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Today, I was working on some optimization and spam-stopping techniques when I encountered Ben Nadel's post to reduce spam feature using Math ( While this method is not o…
    Objective of This Article In 1990’s, when I was a budding software professional, I had a lot of confusion about which stream or technology, I had to choose to build my career. In those days, I had lot of confusion like whether to choose System so…
    The purpose of this video is to demonstrate how to Test the speed of a WordPress Website. Site Speed is an important metric of a site’s health. Slow site speed can result in viewers leaving your site quickly and not seeing your content. This…
    The purpose of this video is to demonstrate how to integrate Mailchimp with WordPress, by placing a Mailchimp signup form on a WordPress Page or Post. This will be demonstrated using a Windows 8 PC. Mailchimp will be used. Log into your Mailchi…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now