# Help to show image

**URL:** <https://www.ruby-forum.com/t/help-to-show-image/181307>\
**Category:** Rails\
**Created:** [January 9, 2010, 8:00am UTC](https://www.ruby-forum.com/t/help-to-show-image/181307 "2010-01-09T08:00:27Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![newb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/2acd7d/32.png) [@newb](https://www.ruby-forum.com/u/newb)\
**Post date:** [January 9, 2010, 8:00am UTC](https://www.ruby-forum.com/t/help-to-show-image/181307/1 "2010-01-09T08:00:27Z")

</div>

Dear friends  
i have used send\_file method to display my html file which is in my  
local server not in rails’s public folder

\<% @file\_path = “#{@prfile.folder\_path}/#{profile.file\_path}” %\>

\<%= link\_to image\_tag(“configure.png”,:title =\> “view profile”),{:action  
=\> “open\_file”,:file\_path =\> @file\_path},{:target =\> ‘\_new’} %\>

def open\_file  
#--------------  
@backup = ProfileBackup.find(:first)  
unlless @backup.nil? and params[:file\_path].nil?  
file\_path = params[:file\_path]  
if File.exists?("#{file\_path}")  
render :file =\> “#{file\_path}”, :layout =\> false  
end  
end  
end

this works fine and open the file in the browser.  
but still it has not shown the image in the file.  
that image also in tat file path .  
but it has not shown the image…  
any helps

---

<div class="post-metadata">

**Author:** ![newb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/2acd7d/32.png) [@newb](https://www.ruby-forum.com/u/newb)\
**Post date:** [January 10, 2010, 1:28am UTC](https://www.ruby-forum.com/t/help-to-show-image/181307/2 "2010-01-10T01:28:29Z")

</div>

On Jan 9, 2:00Â am, Newb N. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> #--------------  
> but still it has not shown the image in the file.  
> that image also in tat file path .  
> but it has not shown the image…  
> any helps

It’s hard to make out what you mean, so I’ll sum up what I _think_  
you’re asking:

- you’ve got an HTML file someplace outside of RAILS\_ROOT/public, that  
you render for the client when they request the open\_file controller  
method.

- images in that file don’t display.

If that’s the case: of COURSE they aren’t going to display. The HTML  
file is returned, but the link to the image likely looks like this:

![]()

What is the actual path that comes up in the address bar when you  
click on the link? I’d bet that it’s NOT:

/controller\_name/open\_file/path/to/some/file

as the file\_path parameter is probably getting escaped…

–Matt J.

---

<div class="post-metadata">

**Author:** ![newb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/2acd7d/32.png) [@newb](https://www.ruby-forum.com/u/newb)\
**Post date:** [January 11, 2010, 4:09am UTC](https://www.ruby-forum.com/t/help-to-show-image/181307/3 "2010-01-11T04:09:19Z")

</div>

Matt J. wrote:

> On Jan 9, 2:00Â am, Newb N. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > #--------------  
> > but still it has not shown the image in the file.  
> > that image also in tat file path .  
> > but it has not shown the image…  
> > any helps
> 
> It’s hard to make out what you mean, so I’ll sum up what I _think_  
> you’re asking:
> 
> - you’ve got an HTML file someplace outside of RAILS\_ROOT/public, that  
> you render for the client when they request the open\_file controller  
> method.
> 
> - images in that file don’t display.
> 
> If that’s the case: of COURSE they aren’t going to display. The HTML  
> file is returned, but the link to the image likely looks like this:
> 
> ![]()
> 
> What is the actual path that comes up in the address bar when you  
> click on the link? I’d bet that it’s NOT:
> 
> /controller\_name/open\_file/path/to/some/file
> 
> as the file\_path parameter is probably getting escaped…
> 
> –Matt J.

Thanks for your reply.  
yes images in that file dont display  
 ![]()  
the actual path that comes up in the address bar when  
click on the link is below  
controller\_name/open\_file/path/to/some/file

Thanks in advance

---

<div class="post-metadata">

**Author:** ![newb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/2acd7d/32.png) [@newb](https://www.ruby-forum.com/u/newb)\
**Post date:** [January 11, 2010, 11:36am UTC](https://www.ruby-forum.com/t/help-to-show-image/181307/4 "2010-01-11T11:36:42Z")

</div>

2010/1/11 Newb N. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> …  
> ![]()  
> the actual path that comes up in the address bar when  
> click on the link is below  
> controller\_name/open\_file/path/to/some/file

I have not studied the whole thread carefully but just looking at your  
link, that will expect to find a MyCaptures route. If the image is in  
a subfolder of public (which would be normal) then you need ![](https://www.ruby-forum.com/MyCaptures/some_image.png). Then it will expect the image to be  
in public/MyCaptures.

Sorry if I have got the wrong end of the stick.

Colin

---

<div class="post-metadata">

**Author:** ![newb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/2acd7d/32.png) [@newb](https://www.ruby-forum.com/u/newb)\
**Post date:** [January 11, 2010, 10:21am UTC](https://www.ruby-forum.com/t/help-to-show-image/181307/5 "2010-01-11T10:21:09Z")

</div>

Any Helps???
