Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7894031
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T07:17:21+00:00 2026-06-03T07:17:21+00:00

I don’t use coldfusion much at all, I’m needed to patch up some code

  • 0

I don’t use coldfusion much at all, I’m needed to patch up some code though. Basically I’m trying to check and see if a file I uploaded exist and if it does exist, increment a variable by 1. Then repeat untill I get a unique file name. For whatever reason I can’t figure out the proper way to use FileExist(). Some forums suggest using it with len() but those are from 2006 and when I do that it seems to always come out true. Also, when I look at http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-7c66.html it says it returns either Yes or No. I tried to check against the result various ways, but no luck.

This is the portion of code I have which I am dealing with. The application.filepath is just a variable in my application file which store the expandpath().

<cffile action="upload" destination="#Application.filePath#ListingsGallery/" filefield="iconImage" nameconflict="makeunique">
<cfset iconPlace = #cffile.serverfile#>
<cfset myExt = listLast(iconPlace,".")>
<cfset i = 1 >
<cfset myVar = false>
<cfloop condition="myVar EQ false">

    <cfset newIconName = "iconPhoto" & i &"."& myExt>
    <cfset iconName = Application.filePath & "ListingsGallery/" & #newIconName#>
<cfoutput>#iconName#</cfoutput><br />//just checking to see if it is the correct path, it is.

    <cfif FileExists(iconName) EQ 'Yes'>
         <cfoutput>#myVar#</cfoutput> //checking the value, it never hits here.
    <cfelse>
             <cfoutput>#myVar#</cfoutput><br /> //checking the value, it always hits here.
    <cfset myVar = true>        
             <cfoutput>#myVar#</cfoutput> //Again check the value.
    </cfif>
<cfset i++>
</cfloop>                     
<cffile action="rename" source="#Application.filePath#ListingsGallery/#iconPlace#" destination="#Application.filePath#ListingsGallery/#newIconName#">

The absolute path on a unix server is something like, /var/www/website folder name/ etc….
Correct? That’s the absolute server path, the coldfusion docs seem to specify at least a microsoft absolute server path so I’m assuming this is what is needed.

Edit—————————
PS: I can’ only give one of you credit, so I gave it to Kruger since he came a minute earlier.
lol…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T07:17:22+00:00Added an answer on June 3, 2026 at 7:17 am

    Assuming your application.Filepath is the correct file path you are on the right track. It looks like your upload directory might be beneath the web root – considering moving it outside the web root for security. Take a look at #expandPath(‘.’)# as a way of creating guaranteed file paths without typos 🙂 Also makes your code more portable.

    To my eye the code above would work. FYI – you don’t need “EQ ‘YES’. You are fine to just do:

    <Cfif FileExists(iconName)>...
    

    You could also do

    condition="NOT myVar">
    

    There are several ways to handle logic code in CF.

    If your fileExists() never hits take a closer look at your rename. Are you throwing an eror?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Don't be frightened, its a very basic code. Just wanted to check with you
Don't they both have to convert to machine code at some point to execute
Don't think there's much to say, here's my code for (int i = 0;
Don't be scared of the extensive code. The problem is general. I just provided
I don't know whether this is really possible, but I'm trying my best. If
I don't want to know a way to preload images, I found much on
Don't know if I worded the question right, but basically what I want to
(Don't know if this is strictly on-topic, but I don't see any better Stack
Don't know how to explain it better but i'm trying to get a response
Don't overlook the 'date AND TIME' part though.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.