I'm pretty sure there's a file size limit as to how much you can store in the database. You will obviously cause some overhead when loading these files from the server as compared to loading natively through just iis. You will also ramp your database file size. In general I find it a very bad idea. Other than it being the easy solution as you put it, I'm not really seeing the rough part of the tradeoff of just saving the path to the images. I don't see it as being a complex algorithm to make all the files unique when cffile already has the nice feature of makeunique for naming conflicts, unless you are wanting to save it with a relatively similar name as the makeunique likes to make up it's own, but then you'd just have to get cffile.serverfile and save it in the database. The only other problem I could possibly forsee is if the whole app or file server picks up and moves, then the paths in the database will have to be updated. Here's the code to upload it to a unique name that's similar to the original if that helps. Also, MX by default uses very similar logic to uniquely name uploaded files by default so you don't even have to worry about it.
 
<cffile action="" filefield="someformfield" destination="#path#" nameconflict="MAKEUNIQUE">
   <cfset wanted = cffile.clientfilename>
   <cfset ext = cffile.clientfileext>
   <cfset attempt = wanted>
   <cfif cffile.serverfilename is not wanted>
    <cfset try = 1>
    <cfset saved = cffile.serverfile>
    <cfloop condition="fileexists('#path##attempt#.#ext#')">
     <cfset attempt="#wanted##try#">
     <cfset try = try + 1>
    </cfloop>
    <cffile action="" source="#path##saved#" destination="#path##attempt#.#ext#">
   </cfif>
   <cfset form.someformfield= "#attempt#.#ext#">
-----Original Message-----
From: Adaryl Wakefield [mailto:[EMAIL PROTECTED]
Sent: Monday, March 10, 2003 10:36 AM
To: [EMAIL PROTECTED]
Subject: [KCFusion] storing files

I have a project where people can track their progress though a training program. One of the things they need to do is view images that they uploaded to our server and there are a couple of other files that relate to them and them only.
The thing I'm agonizing about is rather to store the files (gifs and pdfs) in directories and store the path to the files in a database and coming up with some sort of elaborate algorithm to make sure all the files had unique names OR just storing the gifs and pdfs in the database itself. I've never actually done the latter but I have seen it done with images never with pdfs. The latter method seems easier to me but I read that actually putting the files in the DB creates a performance hit.
Opinions? Wisdom anyone care to share?
Win 2k Server
CF5
SQL Server 2k
A. 

Reply via email to