?
Solved

display an image outside of the cold fusion web root

Posted on 2005-04-26
5
Medium Priority
?
910 Views
Last Modified: 2013-12-24
I have a simple yet time consuming form that has three steps:
Page 1: fill out your info and include an image of yourself
Page 2: preview the information you submitted including the photo uploaded
Page 3: submit your info(the photo has already been saved during Page 2)

The problem here is that the cold fusion/web server cannot access the photo file since it is outside of its tree
G:\sys\uploads\people\images

The closest that I have gotten is by creating a file inside the same folder as the pages above with the following data:
<cfcontent type="image/jpg" file="#form.filePath#" reset="no">
and naming it viewFileContent.cfm

Inside of Page 2 I have this:
<cfinclude template="viewFileContent.cfm">

This works in that I do get to see the photo file although that is the entire content of the page.  I need Page 2 to supply a summary of the information submitted along with the picture uploaded.  I see that the <content> tag has a reset feature that should set wether or not the content outside the tag is discarded, however, it is mutually exclusive from the file attribute and that attribute I cannot get rid of because it has the location of the photo image.

Any hints?
0
Comment
Question by:bisonfur37
  • 3
5 Comments
 
LVL 8

Expert Comment

by:section25
ID: 13870169
Why don't you have page one generate a random key that gets passed to page two which will used as the file name of the uploaded picture into a temp directory. Save the file in a temp directory within the CF tree with the name as the key, then on page two pull up the picture using the key as the name, then when the user submits page two, copy the picture to it's final destination and delete the temp one.

It looks like you are copying the picture to its final destination before the user has verified thier information.
0
 
LVL 8

Expert Comment

by:section25
ID: 13870196
Actually on second thought, you don't necessarily need to do it randomly, you could just use the actual name of the file itself. In step 2, pull it from the temp dir. by it's actual name and then move it in step 3.
0
 
LVL 8

Expert Comment

by:section25
ID: 13870298
Here's the details:

Page 1
------
<SCRIPT LANGUAGE="JavaScript">
 function get_name() {
  var test_array = document.form1.filecontents.value.split("\\");
  var x = test_array.length;
  document.form1.file_name.value=test_array[x-1];
  form1.submit();
 }
</SCRIPT>

<form action="file_upload.cfm" enctype="multipart/form-data" method="post" name=form1>
 Enter the file: <input name="filecontents" type="file" size=60>
 <input name="file_name" type="hidden"><br><br>
 <button onClick=get_name();>Submit</button>
</form>

Page 2 (file_upload.cfm)
------------------------
<cfset pic_name = "#form.file_name#">

<!-- show picture -->
<img src="#pic_name#">

Page 3
------
<!-- move picture -->
<cffile action=move source="#pic_name#" destination="your path">
0
 
LVL 2

Author Comment

by:bisonfur37
ID: 13870949
My simple solution is as follows:

The entire viewFileContent.cfm file is:
<cfcontent type="image/jpg" file="#URL.location#" reset="no">

Then on another page, after the photo has been uploaded do this:
<img src="viewFileContent.cfm?location=#form.filePath#" width="250px"><br />

This works.  The location variable is indeed pointing to a directory outside the document root.
0
 
LVL 9

Accepted Solution

by:
Jerry_Pang earned 1500 total points
ID: 13872703
im using the same cfcontent for my images.

im using to prevent leeching to my site

i got it from here
http://tutorial99.easycfm.com/

in your image tags you use it like this
<img src="http://www.mysite.com/load_image.cfm?Image=logo.jpg" border="0" alt="My Company Logo">

you can place your images outside of root or anywhere in your server.
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
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 …
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses
Course of the Month16 days, 22 hours left to enroll

864 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