Copy link to clipboard
Copied
I'm building an app that requires the user to be able to click a "browse" button, find a file, and click "submit", at which point that filename and path will be saved to a database.
I've been trying to figure out how to create a file dialog in ColdFusion, and the closest I've gotten is <cffile>, but I can't make out how to get that to do what I want.
Any advice?
Copy link to clipboard
Copied
Paul,
Is this for a file on the server or user's computer?
Server files: you might use cfdirectory to get a list (query, really) of files and some of their details then display in cftree or a select list or set of checkboxes (storing the file path as the appropriate field value). It's not a dialog per se but cftree has a nice UI when used properly
User file:
<input type="file" /> (though this doesn't sound like what you're after from the OP)
Copy link to clipboard
Copied
It's actually local, on the user's computer. One of my first CF projects here was to stick our employee directory into a database and build a CF web page to display it to the outside world. Eventually the db got so complicated that I had to build a "back end" to administer it. So it's this "back end" that I'm needing the file dialog box for.
What I'm doing exactly is adding a table to the database to handle page contacts (the people in charge of the content for that particular page). Our office policy states that every web page must have an email contact at the bottom. My current solution to handle this (and I'm all ears if there's a better way) is to have a column full of page names in the /path/filename format. I can a CF include to get the page to find it's own path/name, which it then searches the DB for to find the contact person.
It works fine, but I need an easy way to add new pages to the database, so I thought about using a file dialog to browse and grab the file, then insert the path/filename into the database.
I thought about <input type="file"> but that doesn't let me specify a default directory, so a lot of clicking and finding. I was hoping there was a better way.
Copy link to clipboard
Copied
Bummer. input type="file" is nice to have but definitely not the most user-friendly, as you note.
This is just a suggestion but you might want to look at FCKEditor. It's got some nice file management tools built in that you can customize. Might not fit the bill but wnted to throw it out there just in case...
Copy link to clipboard
Copied
I think my solution is going to be to offer a multiple choice.
The directory structure is like this.
/office/program/subprogram/
So I'll have three <select> lists for those, followed by an <input> to type the filename into.
I can't think of a better way.