Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 180
  • Last Modified:

Date based image viewer

I'm building a ColdFusion image viewing app that needs to be able to automatically insert an image link to an SQL database each day and automatically update the image selection form with that date. The image file names are date based so they are predictable and there will only be one new image each day. I want the past images to be selectable through the image selection form so that the user can select a year and month and day to view an image. The image itself will be generated manually so ColdFusion does not need to be involved in image creation.

Does anyone have an idea of how this can be accomplished in ColdFusion?
0
McHack
Asked:
McHack
  • 4
  • 2
  • 2
  • +3
1 Solution
 
JimV_ATLCommented:
This would be a nice elegant solution.  Name your files in the following form yyyymmdd_filename.jpg

<cfset images_to_display = 3>

<cfset directory = "C:\InetPub\wwwroot\myimages">

<cfdirectory action="LIST" directory="#directory#" name="get_images" filter="*.jpg" sort="name desc">

<cfoutput query="get_images" maxrows="#images_to_display#">
<a href="images/#name#">#name#</a><br><br>
</cfoutput>


0
 
TallerMikeCommented:
OK, so the part about adding the image link to the DB automatically everyday: This isn't really a Cold Fusion thing. You COULD setup a page to do the insert, and then add this page as a scheduled task under the ColdFusion Administrator...but that's still a little funky.

How is the image getting to the server to being with? Is someone copying a file to the drive? Is it being generated by a webcam or something?

Since the file names are predictable, there's really not much of a reason to store their links in the DB. In reality you could just use the day/month/year they select to create an image name, then use FileExists to see if the file exists, and if so output it to the user.

Otherwise, if you do have the images in the DB already, we'll need to know exactly the naming convention that you plan to use.
0
 
McHackAuthor Commented:
The purpose of this app is to allow visitors to view archived images. The images are already online and a new one is created each day and uploaded to the server manually. My reasoning for using the SQL database was that I thought it would be a good way to store links to the images and that an archive form could be made that would use the link data in the database. This would make it possible to make a user friendly interface form to access the image archives. The form itself would increment to include one more selection date based on that days date.

The naming structure of the images is as follows each image is named in a date format like: 030211b.jpg, 030212b.jpg, 030213b.jpg, etc and each months images are stored in folders representing the month like: 01, 02, 03, etc.
0
Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

 
TallerMikeCommented:
Create a page for the user to uplaod the images from. When they upload the image from this page, it will insert the new into the DB, and you can then use this table to select the image URL from whe the user selects the date for the image they want to see.
0
 
DynAstYCommented:
Try inseting the images in to a binary field in MS SQL Server. Then you can reverse it at will for display. I believe MS Access has this capability also.
0
 
TallerMikeCommented:
Inserting BLOB images is not reccommended through Cold Fusion. It has a hard time outputting them.
0
 
DynAstYCommented:
he said "blob" hehehe
0
 
TallerMikeCommented:
lol..what a freak. =)
0
 
anandkpCommented:
hi,

wont having just the image names in the tables & having the images on ur HDD - do the job for u.

u can also have a column for the date - the image was inserted in the DB & keep the image names as u want to ...

whenever u want to output the images based on the date - fire a query in the DB & select the image names u wanna display - then just display teh images

eg :

<cfquery name="x">
    select imagenames from table where imagedate = #Createodbcdate(now())#
</cfquery>

<cfoutput query="x">
   <cfif fileexists('#physical_image_path##imagename#')>
       <img src="#Rel_images_Path##imagename# border="0"><br>
   </cfif>
</cfoutput>

this shld do it for u ... let me know ...

K'Rgds
Anand
0
 
hartCommented:
Anand's suggestion is what i would have suggested too.

hope u work it out that way.

Good show anand :-)

Regards
Harish(hart)
0
 
anandkpCommented:
hello ???
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 4
  • 2
  • 2
  • +3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now