Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
George Smith
Generate a right path
February 26, 2013 3:23 AM
Answer

George Smith

Rank: New Member

Posts: 24

Join Date: January 9, 2013

Recent Posts

Hi!
I save uploaded image files in tomcat or portlet temporary directory, and I want to display them. I know their path in server file system, but how generate a right path for displaying it on portlet's page? It must become from smth like:
opt/liferay/tomcat-7.0.27/temp/28-Image-portlet/WEB-INF/classes/intech/webpro/kegor/image/Clipboard02.jpg

to smth like:
http://localhost:8081/web/guest/liferay-benefits?p_p_id=Image_WAR_Imageportlet&p_p_lifecycle=2&p_p_state=normal&p_p_mode=view&p_p_cacheability=cacheLevelPage&p_p_col_id=column-1&p_p_col_count=1&_Image_WAR_Imageportlet_javax.faces.resource=Clipboard02.jpg&_Image_WAR_Imageportlet_ln=images


How to get it? How to display image from some server directory in portlet?
Hitoshi Ozawa
RE: Generate a right path
February 26, 2013 4:12 AM
Answer

Hitoshi Ozawa

Rank: Liferay Legend

Posts: 7949

Join Date: March 23, 2010

Recent Posts

Not sure what you're trying to do. Images are usually saved in portlet's docroot\img directory.

Access it from a portlet as below:
<%=request.getContextPath()%>/img/image1.png

I just wrote an article (unfortunately in Japanese) explaining how to write a simple slide show portlet.
There's a sample code accessing image file in a portlet. It's a little bit down the page. Looking at the code may help you.

http://gihyo.jp/design/serial/01/liferay/0003?page=4