?
Solved

Cffile upload  in coldfusion 8

Posted on 2009-04-23
2
Medium Priority
?
1,471 Views
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 
                              type</option>
                              <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>
                            </select>
                           <input name="picturedescription" type="hidden" id="picturedescription" value="">
                            Password 
                            <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>
                        </form>
 
<!----Action script that  uploads from form submit --->
 
<cffile action="upload" filefield="Myfile"
destination="C:\Websites\CSR\site.org\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. 
</cfcatch>
</cftry>
<cfif isdefined ("cffile.serverfile")>
 
<cfset PictureURL = "#cffile.serverfile#">
<cfset  ListingID = "#form.listingid# ">
<cfset PictureType = "#form.pictureType#">
<cfset PictureDescription = "#form.pictureDescription#">
<cftry>
 
	<cfquery datasource="dsn" name ="addit">
	Insert into table (ListingID,PictureURL, PictureType,PictureDescription)
	Values (#ListingID#,'#PictureURL#','#PictureType#','#PictureDescription#')
	</cfquery>
<cfcatch type="any">
Table Update Failed
</cfcatch>
</cftry>
 
 
<cfoutput>
Your Photo #PictureURL#, was uploaded.
</cfoutput>
 
<cfelse>
<br />
Upload failed
</cfif>

Open in new window

0
Comment
Question by:LeadCo
2 Comments
 
LVL 27

Assisted Solution

by:azadisaryev
azadisaryev earned 2000 total points
ID: 24212819
>> 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.

Azadi
0
 

Accepted Solution

by:
LeadCo earned 0 total points
ID: 24212926
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\Site.org\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.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Dramatic changes are revolutionizing how we build and use technology. Every company is automating, digitizing, and modernizing operations. We need a better, more connected way to work together as teams so we can harness the insights from our system…
Geo-targeting is the practice of distributing content based on a person’s location, as best as you can determine it. Let’s look at some ways you could successfully use this tactic. The following tips and case studies could lead to meaningful results.
The purpose of this video is to demonstrate how to properly insert a Vimeo Video into a WordPress site or Blog. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp…
The purpose of this video is to demonstrate how to set up the permalinks on a WordPress Website. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Go t…
Suggested Courses

569 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