Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to view a word and pdf document in a coldfusion page

Status
Not open for further replies.

Gill1978

Programmer
Jun 12, 2001
277
GB
How do i upload/ download and view documents in coldfusion. I've used
<img src=&quot;../userPics/#PictureName#&quot; width=&quot;103&quot; height=&quot;146&quot; border=&quot;1&quot; alt=&quot;Picture&quot;>

to view an image saved in a database!

I've managed to save the name of the word file in a SQL Server table and insert the file in a new folder using:

<cfif fileupload1 eq &quot;&quot;>
<cfset file1 = &quot;&quot;>
<cfelse>
<cfset vpath1=GetTemplatePath()>
<cfset vlen=len(vpath1)>
<cfset vpath=left(vpath1,vlen-26)>
<cfset vpath=vpath&&quot;Documents&quot;>

<cffile action=&quot;Upload&quot;
filefield=&quot;fileupload1&quot;
destination=&quot;#vpath#&quot;
nameconflict=&quot;MAKEUNIQUE&quot;>

<cfset file1 = &quot;#File.ServerFileName#&quot; & &quot;.&quot; & &quot;#File.ServerFileExt#&quot;>
</cfif>

But how do i view this document in another page??
 
Here'e what I've done, and you can do with as you will. The primary function of the intranet I am building is to organize and provide web-based access to documentation, so I've done a lot of what you are trying to do.

First, I'll describe my database. I have four tables (Access 2000, BTW) that are relevant to this function. They are: DocumentTable, ProductTable, ProductDocumentTable, and DocTypeTable.
My DocumentTable is structured like this:
DocID (Primary key)
DocFileName (name user gave file)
DocTitle
DocDescription
DocLocation (directory I uploaded to)
DocCreateDateTime
DocModifyDateTime

This is the ProductTable
ProdID (Primary key)
ProdName
ProdDescription
ProdImage
ProdSubset
ProdFamily (we have 3 main ones)

And, here is the DocTypeTable
DocTypeID (Primary key)
DocType (hardware, software, reference, etc.)

Now, for the one that ties it all together, ProductDocumentTable
PD_DocID (Primary key from DocumentTable)
PD_ProdID (Primary key from ProductTable)
PD_DocType (Primary key from DocTypeTable)
PD_Family (same as ProductTable)(Yes, I know it's redundant, but it was a lot easier this way) PD_DocID and PD_ProdID are a combined key for the ProductDocumentTable. I did this because one document may apply to several products, and a product will have many documents accociated with it.

Upload your files, and insert the needed information in the database. In my case, the DocumentTable and the ProductDocumentTable, because the others don't change much.

Having done all that, I simply created queries to retrieve the information on the documents I wanted, and create a link to the actual document on the server.(That's why you need DocLocation). I have four basic pages to present all my documents. On the first page, I present the three product families. The user clicks on one, and ProdFamily is passed to the second page, which lists all the products in that family. The user clicks on a product, and the ProdID is passed to the third page which list the document types. The user selects a document type, and that information is passed to the forth page, which queries the database with all the criteria you have been passing along, and displays (in table form) the documents' title and description. The title is a link (using DocLocation) to the document itself.

That's my very verbose answer, so I hope that's what you were looking for. If you have any more specific questions about how or why I did something, I do my best to answer. (Hopefully more succinctly next time!) Have fun!



Calista :-X
Jedi Knight,
Champion of the Force
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top