Put a <cfdump var="#form#"> at the top of the action to make sure the field
is even there. Then recheck your form tags, enctype, fieldnames etc...

I usually just use 

<cfparam name="form.image_file" default="">

<cfif len(trim(form.image_file))>
        <!--- try to upload the file --->
<cfelse>
        <!--- don't --->
</cfif>


-----Original Message-----
From: Daniel Kessler [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, August 16, 2005 8:56 AM
To: CF-Talk
Subject: uploading an image

I'm trying to upload an image to a particular directory to use later. 
I grabbed this code from a working form I made when I was new to CF 
and I cleaned it up.  Funny enough, now that it's cleaned up, it's 
not working and I can't see why.  It appears that it's saying that 
the form field (form.image_file) never exists, whether I have 
selected an image/file or not.

Here's the form field:
<strong>Image:</strong><br><input type="File" name="image_file" size="60">

which when submitted then goes to an INSERT page which has the 
following image code:

<cfif NOT structKeyExists(form,'image_file')>
         <cfset Form.image_file = "">
<cfelse> 
                        <!--- check the CGI environment variable 
Content_Length to make sure the file is less than 1 MB in size. --->
<CFIF Val(CGI.CONTENT_LENGTH) GT 1048576>
         Please select another from the <a 
href="javascript:history.go(-1);">spotlight form</a>.
         <cfabort>
</CFIF>
 
                <cfset 
mainDir=GetDirectoryFromPath(ExpandPath("../../"))>
<cftry>
         <cffile
                 action="upload"
                 filefield="image_file"
                 destination="#mainDir#uploads/spotlight/"
 
accept="image/jpeg,image/jpg,image/gif,image/pjpeg,image/jpe"
                 nameconflict="MakeUnique">

         <cfcatch type="Any">
                 <cflocation 
url="spotlight_entry.cfm?fileuploaderror=true&msg=#cfcatch.message#" 
addtoken="No">
         </cfcatch>
</cftry>

<cfset image_path = '#CFFILE.serverFileName#.#CFFILE.ServerFileExt#'>
</cfif>

<--- do an insert here --->
-- 
Daniel Kessler

Department of Public and Community Health
University of Maryland
Suite 2387 Valley Drive
College Park, MD  20742-2611
301-405-2545 Phone
www.phi.umd.edu



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Discover CFTicket - The leading ColdFusion Help Desk and Trouble 
Ticket application

http://www.houseoffusion.com/banners/view.cfm?bannerid=48

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:215238
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to