• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 173
  • Last Modified:

securing pdf files in an application

Hi there.

Im trying to build an application that secures pdf files so that no one can upload them just by typing in the url.
They need to be in a secured directory and then accessed via a coldfusion page.
I have tried this but the only way I can seem to do this is via:

<cfheader
name="Content-Disposition"
value="attachment; filename=#filename#">
<cfcontent
type="application/unknown"
file="#filepath#">

Ive tried using application/pdf to display the page in the browser but all this seems to do is output the actual pdf code.
Any ideas?

Also thinking about storing the pdf's in a sql server database. Has anyone had any experience with this and also retrieving the pdf files?

Thanks Heaps
0
ipulse2
Asked:
ipulse2
2 Solutions
 
ftvcsCommented:
I'd try something like this:

<cfif CGI.HTTP_REFERER eq"frompage.cfm">
<cfcontent type = "application/pdf"
  file = "c:\files\files1.pdf"> <!--- path not accesible from internet--->
</cfif>

If you have questions, don't hesitate to ask.

Tom
0
 
shooksmCommented:
This works for me:

<cfheader name="content-disposition" value="inline;filename=#URLEncodedFormat(filename)#">
<cfcontent type="application/pdf" file="#filepath#" reset="yes">

Also, make sure your PDF files actually end with a PDF extension.

As far as saving them in the database, although it is possible.  It is not recommended.  The file system of your webserver is much faster at retrieving files than making a call do a database server.  Also, you can not output binary variables directly from Cold Fusion.  You have to save them as a local file using CFFILE then you use CFCONTENT to send them to the browser.  So, since you are sticking the file on the hard drive of the web server anyways, why not just keep it there in the first place.  Hope this helps.
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now