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 8821229
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T05:48:02+00:00 2026-06-14T05:48:02+00:00

My form allows users to select a directory to view the files contained within

  • 0

My form allows users to select a directory to view the files contained within it:

(files.cfm)

<form action="#buildURL('main.files')#" method="post">

        <!--- Show the subfolder path, unless already at top level --->
        <cfif subfolderPath EQ "">
            <h2>You are at the top level.</h2>
        <cfelse>
            <h2>Current Folder: #subfolderPath#</h2>
        </cfif>

        <!--- Provide a drop-down list of subfolder names --->
        Select folder:
        <select name="subfolderPath" onChange="this.form.submit()">
            <!--- Provide an option to go up one level to the parent folder, --->
            <!--- unless already at the BaseFolder --->
            <cfif listLen(subfolderPath, "/") gt 0>
                <cfset parentFolder = listDeleteAt(subfolderPath, listLen(subfolderPath, "/"), "/")>
                <option value="#parentFolder#">[parent folder]</option>
            </cfif>

            <!--- For each record in the query returned by <cfdirectory> --->
            <cfloop query="DirectoryQuery">
                <!--- If the record represents a subfolder, list it as an option --->
                <cfif Type eq "Dir">
                    <option value="#subfolderPath#/#Name#">#Name#</option>
                </cfif>
            </cfloop> 
        </select>

        <!--- Submit button to navigate to the selected folder --->
        <input type="submit" value="go">
    </form> 

When the files are displayed, there is a delete feature that calls another page:

<td align="absmiddle"><a href="#buildUrl('main.deleteFile?filename=#name#&folder=#rereplace(subFolderPath, '/','')#')#" onClick="alert('Are you sure you want to delete this file?')"><img src="/art/assets/images/delete.png" title="delete file" /></a></td>

On the deleteFile page (deleteFile.cfm), the file is deleted:

<cfset local.filePath = ExpandPath( ".\upload\views\files\#rereplace(url.folder, '/','')#\" ) />
    <cffile action="delete"
            file="#local.filePath##url.filename#"
    />

The user is then sent back to the previous page:

<cflocation url="#buildUrl('main.files')#" />

But not within the same view of the directory from which the file was just deleted. How may I return the user to the files page and maintain the view of the directory he was in?

  • 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-14T05:48:04+00:00Added an answer on June 14, 2026 at 5:48 am

    I can think of a couple methods

    First, you can call the delete action file with AJAX. Once it completes successfully, remove the element from your current page. This is the fancy way, but may be difficult to pull off, as it looks like you may be somewhat new to this.

    Second, you can send the context of your current page along to the delete file (the subFolderPath variable), add it to the cflocation when you redirect. It looks like you already have it with the url.folder variable, so you would do this:

    <cflocation url="#buildUrl('main.files', "subfolderPath=#rc.folder")#" />
    

    It looks like you’re using FW/1, so I assumed ‘buildURL()’ works as advertised, and your url & form variables are in the rc scope.

    Once you arrive back on your initial page from the cflocation, you will want to put the selection back on the folder you had selected. In your loop that creates the <option> tags, add a check to see if an option should be selected. I would usually do something like this:

    <option value="..." <cfif listLast(rc.subFolderPath,"\") EQ name>selected</cfif>>#name#</option>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form selection that allows users to select a product from a
I'm creating simple payment form that allows users to select from several different gateways
I have a form with a select list that allows users to choose multiple
I have a form that allows users to enter a date of birth: ie:
I have a Rails form that allows users to update the values of a
I need to develop custom login form which allows user to select language (locale).
I am trying to make a page that allows users to select 8 checkboxes
I have a search form on my website that allows users to search for
I have a search form that allows users to search on several different fields
I'm creating a form that allows users to upload 11 images, i have 11

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.