Read from directory add to db

Posted on 2005-04-05
Last Modified: 2013-12-24

I am running CFMX 7 on our own server Win 2003. 800gb space,

I have just set up a new web directory structure with over 6000 images in it set up like below.

wwwroot/pics/summmer/img_2453663_66357.jpg  (etc)
wwwroot/pics/winter/img_2453663_66311.jpg  (etc)

Lots of folders with hundreds of images in each.

What i need to do is for coldfusion to read the name of the images, and store it and it's route on a db (don't worry about the storage code that is not a problem)

Something behind this... I have an co located server with 600 thumbnails on it live, the order form is currently sent to the account manager who finds the 300dpi image on the server and sends it out on a CD, as you can see this is not the best way.

What i have is set up our inhouse server with the 300dpi images on, i am going to pass the image name accross from the current order form and send out the image.

I do not want to type in 6000+ image names and locations?

Please any help?
Question by:zakaz
    LVL 20

    Expert Comment


    This is just an idea and somthing I haven't tried before, but may be of some use???

    <cffile    action = "read"    
                 file = "../pics/summmer/"  
                 variable = "pic_locations"   >


    I don't have any idea if this will work, at the moment I don't have anythnig to test on either :o)

    just an idea...
    LVL 1

    Expert Comment

    Are you wanting to do this as images are uploaded to the server as part of a web app?  Do you just want to be able to find an image based upon it's name?  There are a couple of different approaches based upon your unique requirements and all should be rarther simple.  Can you give us a little more information to work with?
    LVL 20

    Expert Comment

    I'm not sure exactly how to go about this,

    but what I believe he is asking is how to dynamically populate a database record say "Image_Name" with the name of images in a directory (he says about 600 worth) and store another value "Image_Location" with the path to those images in a table without having to hand cramp everything to the table...

    by say storing the values as variables and doing an SQL insert to update his new database.

    I would also be interested if you have an easy way of doing this!

    I think then he can use this table to call images on a variety of pages with his new database..?

    LVL 12

    Accepted Solution

    We did this a while back, cfdirectory is your friend:
    This is done with no testing, so you may need to tweak it a bit.

    <cfdirectory action="list" name="pics" directory="c:/wwwroot/pics/" >

    <cfloop query="pics">
          <cfdirectory action="list" name="this" directory="c:/wwwroot/pics/">
          <cfloop query="this">
                <!--- contains all the file names in your directory --->
                <!--- You can use this info to store in db --->

    Author Comment

    Excellent work you guys,

    I will give these a taet today,

    Thank You all,


    Author Comment

    <p>The template path of the current page is:

    <cfdirectory action="list" name="pics" directory="E:\wwwroot\Clients\b\bdw\images\" >

      <cfloop query="pics">
         <cfdirectory action="list" name="this" directory="E:\wwwroot\Clients\b\bdw\images\">
         <cfloop query="this">
              <!--- contains all the file names in your directory --->
              <!--- You can use this info to store in db --->

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Suggested Solutions

    Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
    Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now