1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Uploading images to my website server - error saving to server

Discussion in 'Programming' started by lespaul00, Nov 22, 2007.

  1. #1
    Hello,

    I created a page where people can submit images to my webpage. All I want, is to enable anyone to upload an image, then, I can go into the folder where these images are saved, and look at them.

    Here is my code (cf_upload.cfm):

    <body>
    <cfif isdefined("form.upload_now")>
    <cffile action="upload" filefield="ul_path" destination="ftp://216.15.150.140/wwwroot/upload/" accept="image/jpeg, image/gif, image/jpg, image/svg, image/pjpeg, image/pjpg, image/png, image/x-png" nameconflict="makeunique">
    The file was successfully uploaded!
    </cfif>
    
    <form action="cf_upload.cfm" method="post" name="upload_form" enctype="multipart/form-data" id="upload_form">
    <input type="file" name="ul_path" id="ul_path">
    <input type="submit" name="upload_now" value="submit">
    </form>
    </body>
    Code (markup):
    I get an error when I attempt this:

    Should I not write in the ftp address? (this is where I go to upload my website files).

    How do I make sure the files uploaded are safe (besides only allowing certain image file types)?

    How do I prevent the Coldfusion error message to appear for a user, and instead, a custom message that I create?

    Thanks!!!
     
    lespaul00, Nov 22, 2007 IP
  2. cfStarlight

    cfStarlight Peon

    Messages:
    398
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    No. It should be a physical path on the server like c:\cfusionmx7\wwwroot\myfiles. You can use ExpandPath() to get the path dynamically

    
    <cfoutput>
    Current path: #ExpandPath("./")#<br>
    Up one level: #ExpandPath("../")#<br>
    </cfoutput>
    
    Code (markup):
    Here are some tips:

    http://www.mail-archive.com/cf-talk@houseoffusion.com/msg232169.html
    http://samsinger.blogspot.com/2007_06_01_archive.html
    Upload to a directory outside of the web root. Always check the File Extension (cffile.serverFileExt. Check File Names as well.



    You can use cftry/cfcatch. Catch the error and display whatever error message you want
    http://livedocs.adobe.com/coldfusion/7/htmldocs/00001142.htm
     
    cfStarlight, Nov 22, 2007 IP
  3. lespaul00

    lespaul00 Peon

    Messages:
    283
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Ok, that makes sense. But how do I know where this is?

    I can open my ftp server link in windows explorer, and create a new folder. This is where I'd want the uploaded images to go. When "I" go to this folder location, it is: ftp://216.15.150.140/wwwroot/upload/. So, I guess I don't know how to change this to make it work (in the RED portion below):

    <body>
    <cfif isdefined("form.upload_now")>
    <cffile action="upload" filefield="ul_path" destination="[COLOR="Red"]ftp://216.15.150.140/wwwroot/upload/[/COLOR]" accept="image/jpeg, image/gif, image/jpg, image/svg, image/pjpeg, image/pjpg, image/png, image/x-png" nameconflict="makeunique">
    The file was successfully uploaded!
    </cfif>
    
    <form action="cf_upload.cfm" method="post" name="upload_form" enctype="multipart/form-data" id="upload_form">
    <input type="file" name="ul_path" id="ul_path">
    <input type="submit" name="upload_now" value="submit">
    </form>
    </body>
    Code (markup):
     
    lespaul00, Nov 22, 2007 IP
  4. cfStarlight

    cfStarlight Peon

    Messages:
    398
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Use ExpandPath().

    I don't know how your FTP url corresponds to your physical site structure. The easiest way to figure it out is to play around with expandPath() function on your cfm page.

    For example #ExpandPath("/")# should give you the path of the site root. #ExpandPath("./")# should give the current directory, etc..

    Try a few combinations like

    #ExpandPath("/upload")#
    #ExpandPath("/wwwroot/upload")#

    and you should figure it out.
     
    cfStarlight, Nov 22, 2007 IP
  5. lespaul00

    lespaul00 Peon

    Messages:
    283
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Thanks a bunch. You're awesome.

    Is there a way to limit the file size of the uploaded image? I'm sure there's a simple code to do this.

    I found the following on the internet:

    <!--- Create a ColdFusion image named "myImage" from a file uploaded to the server. --->
    <cfimage action="read" source="#fileUpload.serverFile#" name="myImage">
    <!--- Determine whether the file is greater than 300 pixels in width or height. --->
    <cfif ImageGetHeight(myImage) gt 300 or ImageGetWidth(myImage) gt 300>
        <!--- If the file exceeds the size limits, delete it from the server. --->
        <cffile action="delete" file="#fileUpload.serverDirectory#/#fileUpload.serverFile#">
        <cfoutput>
    <!--- Display the following message. --->
        <p>
        The image you uploaded was too big. It must be less than 300 pixels wide and 300 pixels
            high. Your image was #imageGetWidth(myImage)# pixels wide and
            #imageGetHeight(myImage)# pixels high.
        </p>
    </cfif>
    Code (markup):
    However, I do not see the logic of how to integrate it into my code:

    <body>
    <cfif isdefined("form.upload_now")>
    <cffile action="upload" filefield="ul_path" destination="#ExpandPath("/upload")#" accept="image/jpeg, image/gif, image/jpg, image/svg, image/pjpeg, image/pjpg, image/png, image/x-png" nameconflict="makeunique">
    The file was successfully uploaded!
    </cfif>
    
    <form action="cf_upload.cfm" method="post" name="upload_form" enctype="multipart/form-data" id="upload_form">
    <input type="file" name="ul_path" id="ul_path">
    <input type="submit" name="upload_now" value="submit">
    </form>
    </body>
    Code (markup):
    I see this restricts file size to height and width. Maybe it'd be easier to restrict file "size" (50kb, 100kb?)?
     
    lespaul00, Nov 22, 2007 IP
  6. cfStarlight

    cfStarlight Peon

    Messages:
    398
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #6
    When you use cffile it returns a structure named CFFILE containing all sorts of good information. IIRC CF8 allows you to give it a different name, but for MX6/7 its always called CFFILE.

    http://livedocs.adobe.com/coldfusion/6.1/htmldocs/tags-p35.htm#wp3540091

    After you upload with <cffile>, check the file size using the CFFILE.fileSize variable. If the file is too big, then delete it and display an error. AFAIK, you can't check the size before you upload, at least not using just CF.

    
    	<cfoutput>
    	Was the file saved? #CFFILE.fileWasSaved#<br>
    	File size is #CFFILE.fileSize# bytes<br>
    	File was saved to directory: #CFFILE.serverDirectory#<br>
    	File was saved as: #CFFILE.serverFile#<br><br>
    	</cfoutput>
    	<!--- the file size is in bytes. must convert to KB --->
    	<!--- 100KB == (100 * 1024) --->
    	<cfif CFFILE.fileSize GT (100 * 1024)>
    		Sorry your file is too big! 
    		<!--- if its too big, delete the file --->
    		<!--- Note - The file separator depends on your O/S --->
    		<!--- File separator for windows is "/" --->
    		<cffile action="delete" file="#CFFILE.serverDirectory#\#CFFILE.serverFile#">
    	</cfif>
    
    Code (markup):

    You might also be interested in this function at cflib.org. It converts size in bytes to KB,MB, etc.

    http://www.cflib.org/udf.cfm?ID=757
     
    cfStarlight, Nov 22, 2007 IP
  7. cfStarlight

    cfStarlight Peon

    Messages:
    398
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Do you want to restrict the images by size or by height/width?

    Also, what version of CF are you using? I think CF8 has some built in functions for that.
     
    cfStarlight, Nov 22, 2007 IP
  8. lespaul00

    lespaul00 Peon

    Messages:
    283
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    I am using Coldfusion MX7.

    I would like to restrict it by file size, (probably 150kb), not height and width.

    Also, I figured I'd create another table in my database... so I know who uploaded the file.

    New table name = UPLOAD

    UPLOAD_ID....DISPLAY_NAME.....FILE_NAME


    I would like the form to have a field for the user to input his/her display name, and also the browse button for them to submit the image. However, ...

    1. I do not know how to get the file name into the database field (so I know which file this person uploaded into the folder)

    2. How to ensure the user fills out both fields.

    Also, I tried adding your code, but I receive an error (attached):

    [CODE<body>

    <h1>Submit a recipe </h1>
    <form action="cf_upload.cfm" method="post" name="upload_form" enctype="multipart/form-data" id="upload_form">
    Your display name:
    <input name="DISPLAY_NAME" type="text" value="Enter your display name" size="25" maxlength="200" />

    <p>Browse for your file you wish to upload:
    <p>
    <input name="ul_path" type="file" id="ul_path" size="30">
    <input type="submit" name="upload_now" value="submit">
    </form> </p>
    <cfif isdefined("form.upload_now")>
    <cffile action="upload" filefield="ul_path" destination="#ExpandPath("/upload")#" accept="image/jpeg, image/gif, image/jpg, image/svg, image/pjpeg, image/pjpg, image/png, image/x-png" nameconflict="makeunique">
    <p>Your file was successfully uploaded! It will be reviewed. Thank you! </p>
    </cfif>
    <CFQUERY DATASOURCE="mydatasource" NAME="UPLOAD">

    INSERT INTO UPLOAD(DISPLAY_NAME)

    VALUES('#form.DISPLAY_NAME#')

    </CFQUERY>





    <cfoutput>
    Was the file saved? #CFFILE.fileWasSaved#<br>
    File size is #CFFILE.fileSize# bytes<br>
    File was saved to directory: #CFFILE.serverDirectory#<br>
    File was saved as: #CFFILE.serverFile#<br><br>
    </cfoutput>
    <!--- the file size is in bytes. must convert to KB --->
    <!--- 100KB == (100 * 1024) --->
    <cfif CFFILE.fileSize GT (100 * 1024)>
    Sorry your file is too big!
    <!--- if its too big, delete the file --->
    <!--- Note - The file separator depends on your O/S --->
    <!--- File separator for windows is "/" --->
    <cffile action="delete" file="#CFFILE.serverDirectory#\#CFFILE.serverFile#">
    </cfif>
    </body>
    </html>
    [/CODE]


    Error:

     
    lespaul00, Nov 22, 2007 IP
  9. cfStarlight

    cfStarlight Peon

    Messages:
    398
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Okay. Then just compare the uploaded file size to
    <cfset maxFileSize = (150 * 1024)>


    The <cfif> statements aren't nested correctly. I think it should be more like this

    
    <cfif isdefined("form.upload_now")>
    	<cffile action="upload" filefield="ul_path" destination="#ExpandPath("/upload")#" accept="image/jpeg, image/gif, image/jpg, image/svg, image/pjpeg, image/pjpg, image/png, image/x-png" nameconflict="makeunique">
    	<!--- the file size is in bytes. must convert to KB --->
    	<!--- 100KB == (100 * 1024) --->
    	<cfif CFFILE.fileSize LTE (100 * 1024)>
    		<CFQUERY DATASOURCE="mydatasource" NAME="UPLOAD">
    			INSERT INTO UPLOAD(DISPLAY_NAME)
    			VALUES('#form.DISPLAY_NAME#')
    		</CFQUERY>
    		<p>Your file was successfully uploaded! It will be reviewed. Thank you! </p>
    	<cfelse>
    		Sorry your file is too big! 
    		<cffile action="delete" file="#CFFILE.serverDirectory#\#CFFILE.serverFile#">
    	</cfif>
    </cfif>
    
    Code (markup):
    You can use #CFFILE.serverFile#. It will work once you fix the cfif statements.

    
    <CFQUERY DATASOURCE="mydatasource" NAME="UPLOAD">
       INSERT INTO UPLOAD(DISPLAY_NAME, FILE_NAME)
       VALUES
       ( 
       <cfqueryparam value="#form.DISPLAY_NAME#" 
              cfsqltype="cf_sql_varchar">, 
       <cfqueryparam value="#CFFILE.serverFile#" cfsqltype="cf_sql_varchar"> 
       )
    </CFQUERY>
    
    Code (markup):
    You could use CFFORM and CFINPUT and set the fields to required="true". Then CF would automatically validate the fields arent' empty. But that relies on javascript, so you should also do validation on the server.

    - verify that len(trim(form.DISPLAY_NAME)) GT 0
    - verify that len(trim(form.ul_path)) GT 0

    The second is very a rudimentary test. Not at all bullet-proof. You'll still have to use acftry/cfcatch to handle conditions like empty files, wrong file type, etc.
     
    cfStarlight, Nov 22, 2007 IP
  10. lespaul00

    lespaul00 Peon

    Messages:
    283
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #10
    Thanks for the information. I think it was a lot to digest for me. I have the form up and running, and it does the following:

    1. Uploads the file I browse for (regardless of size).

    What it does not do:

    1. It does not restrict the file size to 150kb (I successfully uploaded a 2.4 MB file)
    2. It does not insert DISPLAY_NAME and FILE_NAME values into my UPLOAD table of my database.
    3. It still says "File uploaded successfully" even when the DISPLAY_NAME field is left blank.

    This is the most current version of the code I am using:

    <h1>Submit a recipe image</h1>
    [B][COLOR="Red"]	<!--- set the maximum file size--->[/COLOR][/B]
    <cfset maxFileSize = (150 * 1024)>
    [B][COLOR="Red"]	<!--- my form--->[/COLOR][/B]
    <form action="cf_upload.cfm" method="post" name="upload_form" enctype="multipart/form-data" id="upload_form">
    [B][COLOR="Red"]	<!--- display name form field--->[/COLOR][/B]
    Your display name: 
    <input name="DISPLAY_NAME" type="text" value="Enter your display name" size="25" maxlength="200" />
    [B][COLOR="Red"]	<!--- image upload form field--->[/COLOR][/B]
    <p>Browse for your file you wish to upload: 
    <input name="ul_path" type="file" id="ul_path" size="30">
    [B][COLOR="Red"]	<!--- submit button--->[/COLOR][/B]
    <input type="submit" name="upload_now" value="submit">
    </form> </p>
    
    [B][COLOR="Red"]	<!--- validation that image is correct format--->[/COLOR][/B]
    <cfif isdefined("form.upload_now")>
    	<cffile action="upload" filefield="ul_path" destination="#ExpandPath("/upload")#" accept="image/jpeg, image/gif, image/jpg, image/svg, image/pjpeg, image/pjpg, image/png, image/x-png" nameconflict="makeunique">
    [B][COLOR="Red"]	<!--- conversion of file size to proper units--->[/COLOR][/B]
    	<!--- the file size is in bytes. must convert to KB --->
    	<!--- 100KB == (100 * 1024) --->
    	<cfif CFFILE.fileSize LTE (100 * 1024)>
    [B][COLOR="Red"]	<!--- query to save to UPLOAD table of my database.  Inserts DISPLAY_NAME into field DISPLAY_NAME and FILE_NAME into field FILE_NAME--->[/COLOR][/B]
    <CFQUERY DATASOURCE="mydatasource" NAME="UPLOAD">
       INSERT INTO UPLOAD(DISPLAY_NAME, FILE_NAME)
       VALUES
       ( 
       <cfqueryparam value="#form.DISPLAY_NAME#" 
              cfsqltype="cf_sql_varchar">, 
       <cfqueryparam value="#CFFILE.serverFile#" cfsqltype="cf_sql_varchar"> 
       )
    </CFQUERY>
    [B][COLOR="Red"]	<!--- Message displayed if 1. the image was the proper format, 2. the image was under 150kb, 3. The DISPLAY_NAME field was filled out--->[/COLOR][/B]
    <p>Your file was successfully uploaded! It will be reviewed. Thank you! </p>
    	<cfelse>
    [B][COLOR="Red"]	<!--- Message if one of the criteria above was not met--->[/COLOR][/B]
    		Sorry your file is too big! 
    		<cffile action="delete" file="#CFFILE.serverDirectory#\#CFFILE.serverFile#">
    	</cfif>
    </cfif>
    Code (markup):
     
    lespaul00, Nov 23, 2007 IP
  11. cfStarlight

    cfStarlight Peon

    Messages:
    398
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #11
    Yes, it is a lot of information. Try adding the code one step at a time to better see which part isn't working

    1. First fix the <cfif> nesting (if you haven't already)
    2. Once that's working, try checking the file size / delete code
    3. Next try adding CFFORM to make the fields required with javascript
    4. Next add the server validation to make the fields required
    5. Add the query to insert the information into the database

    Which step are you starting with?
     
    cfStarlight, Nov 23, 2007 IP
  12. lespaul00

    lespaul00 Peon

    Messages:
    283
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #12
    I fixed #1 with your suggestion, and do not receive any error message. So, I assume the nesting is fine.

    For #2, I guess I need to understand it a bit. For instance, what exactly does this mean?

    <cfif CFFILE.fileSize LTE (100 * 1024)>
    
    Code (markup):
    LTE? I guess this may mean less than? Also, if this is true, will it execute the UPLOAD query?

    FOr #3... do you mean to change the <form> that I have:

    <form action="cf_upload.cfm" method="post" name="upload_form" enctype="multipart/form-data" id="upload_form">
    Code (markup):
    with cfform, as such?

    <[COLOR="Red"][B]cf[/B][/COLOR]form action="cf_upload.cfm" method="post" name="upload_form" [COLOR="red"][B]required="true"[/B][/COLOR] enctype="multipart/form-data" id="upload_form">
    Code (markup):
    #4: i'm not sure how to do this

    #5: The code I have so far:

    <CFQUERY DATASOURCE="mydatasource" NAME="UPLOAD">
       INSERT INTO UPLOAD(DISPLAY_NAME, FILE_NAME)
       VALUES
       ( 
       <cfqueryparam value="#form.DISPLAY_NAME#" 
              cfsqltype="cf_sql_varchar">, 
       <cfqueryparam value="#CFFILE.serverFile#" cfsqltype="cf_sql_varchar"> 
       )
    </CFQUERY>
    
    Code (markup):
    But I guess I will try on steps #1 - #3 first.
     
    lespaul00, Nov 23, 2007 IP
  13. cfStarlight

    cfStarlight Peon

    Messages:
    398
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #13
    LTE is an operator meaning "less than or equal to". So what you're doing is comparing the size of the file with the maximum size you want to allow (ie 100KB).

    Since the CFFILE.fileSize is in bytes you have to convert 100KB to bytes.

    ie 100 (KB) x 1024 (which is the number bytes per KB)

    Here is an example using 150KB. Try this and if it works, move on to the next step.

    
    <cfif isdefined("form.upload_now")>
    	<!--- ie 150KB.  1024 bytes == 1KB --->
    	<cfset maxFileSize = (150 * 1024)>
    
    	<cffile action="upload" filefield="ul_path" destination="#ExpandPath("/upload")#" accept="image/jpeg, image/gif, image/jpg, image/svg, image/pjpeg, image/pjpg, image/png, image/x-png" nameconflict="makeunique">
    	<cfif CFFILE.fileSize LTE maxFileSize>
    		<p>Your file was successfully uploaded! It will be reviewed. Thank you! </p>
    	<cfelse>
    		<!--- Message if one of the criteria above was not met--->
    		Sorry your file is too big! 
    		<cffile action="delete" file="#CFFILE.serverDirectory#\#CFFILE.serverFile#">
    	</cfif>
    </cfif>
    
    Code (markup):
     
    cfStarlight, Nov 23, 2007 IP
  14. cfStarlight

    cfStarlight Peon

    Messages:
    398
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #14
    The file will always be uploaded. The code then checks the size of the file and deletes it if it's too big (ie 100KB or whatever max size you use).

    The reason for this is because its not possible to check the file size before you upload, at least with plain CF.
     
    cfStarlight, Nov 23, 2007 IP
  15. cfStarlight

    cfStarlight Peon

    Messages:
    398
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #15
    Yes.

    
    <h1>Submit a recipe </h1>
    <cfform action="cf_upload.cfm" method="post" name="upload_form" enctype="multipart/form-data" id="upload_form">
    	Your display name:
    	<cfinput name="DISPLAY_NAME" 
    			type="text" 
    			[B][COLOR="Red"]value="" [/COLOR][/B]
    			size="25" 
    			maxlength="200" 
    			required="true" 
    			message="Please enter a display name!"/>
    
    	<p>Browse for your file you wish to upload:
    	<p>
    	<cfinput name="ul_path" 
    			type="file" 
    			id="ul_path" 
    			size="30"
    			required="true"
    			message="Please select a file to upload!">
    	<cfinput type="submit" name="upload_now" value="submit">
    	</p>
    </cfform>
    
    Code (markup):
     
    cfStarlight, Nov 23, 2007 IP
  16. lespaul00

    lespaul00 Peon

    Messages:
    283
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #16
    Ok great. I implemented the necessary changes.

    Unfortunately, now, I get an error:

    It MUST be an issue with my query, because when I remove the query, there is no error.

    Also, with the query not working, there is no way for me to test the size constraint on file size.

    I tried changing the following changes:

    <CFQUERY DATASOURCE="mydatabase" NAME="UPLOAD">
    		   INSERT INTO UPLOAD(DISPLAY_NAME, FILE_NAME)
    		   VALUES
    		   ( 
    		   <cfqueryparam value="#[COLOR="Red"][B]cf[/B][/COLOR]form.DISPLAY_NAME#" 
    				  cfsqltype="cf_sql_varchar">, 
    		   <cfqueryparam value="#CFFILE.serverFile#" cfsqltype="cf_sql_varchar"> 
    		   )
    </CFQUERY>
    Code (markup):
    and

    <CFQUERY DATASOURCE="mydatabase" NAME="UPLOAD">
    		   INSERT INTO UPLOAD(DISPLAY_NAME, FILE_NAME)
    		   VALUES
    		   ( 
    		   <cfqueryparam value"#[COLOR="red"][B]upload_form[/B][/COLOR].DISPLAY_NAME#" 
    				  cfsqltype="cf_sql_varchar">, 
    		   <cfqueryparam value="#CFFILE.serverFile#" cfsqltype="cf_sql_varchar"> 
    		   )
    </CFQUERY>
    Code (markup):
    These both didn't work. I figured, that since it's saying DISPLAY_NAME is undefined in the FORM portion of the query, that maybe I needed to revise it to know where the data is coming from (the cfform field).
     
    lespaul00, Nov 23, 2007 IP
  17. cfStarlight

    cfStarlight Peon

    Messages:
    398
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #17
    Doesn't matter if you're using an html form <form> or <cfform> or what your form is named. The form fields will always be in a scope named FORM.

    #FORM.DISPLAY_NAME#
     
    cfStarlight, Nov 23, 2007 IP
  18. cfStarlight

    cfStarlight Peon

    Messages:
    398
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #18
    Did you do #4 yet?
     
    cfStarlight, Nov 23, 2007 IP
  19. lespaul00

    lespaul00 Peon

    Messages:
    283
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #19
    Ok, this is the original syntax I had. So why would I be receiving this error?


    As for...

    I really don't understand how this is done, or frankly, what it means.

    Is it something I'll have to go in and tweak within my website settings (web hosting settings?)
     
    lespaul00, Nov 23, 2007 IP
  20. cfStarlight

    cfStarlight Peon

    Messages:
    398
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #20
    Could be a number of things
    1. The form field name is wrong
    2. The form uses <cfform method="get"...> instead of <cfform method="post"...>
    3. The code is in the wrong place so the variable isn't defined

    Add some debug code so you can see what's going wrong. What results do you get?

    
       <cfif isdefined("form.upload_now")>
           <!--- show what was posted before any errors can occur --->
          FORM scope contains:
          <cfdump var="#FORM#">
          URL scope contains:
          <cfdump var="#URL#">
           .... rest of the code ...
       </cfif>
    
    Code (markup):
     
    cfStarlight, Nov 23, 2007 IP