Hello all,
I currently have a portlet with a file explorer and a blank pane. When the user selects to open an image file, I would like to display the image in the pane.
However, the image exists in /home/myUser/images/ and the portlet exists in /home/server/tomcat/tomcat-6.0.18/webapps/mycompany. It is placed there by hotdelploying a portlet through Liferay. Basically, in the code i want to be able to geenerate some html to display that image. However, I know I cant just say
<img src='/home/myUser/images/test.jpg'/>
from within my portlet. So, I thought about copying it over into the tomcat-6.0.18/temp directory using the File.createTempFile method. I successfully copy the file there, and it is there. However, when I now say
<img src='/home/server/tomcat/tomcat-6.0.18/temp/test.jpg'/>
I still cant display it! Note: the text above comes from:
File tempImage = File.createTempFile("","");
FileReader in = new FileReader(myImageFile);
FileWriter out = new FileWriter(tempImage);
int c;
while ((c = in.read()) != -1)
out.write(c);
in.close();
out.close();
String myHtmlString = "<img src='" + tempImage.getAbsolutePath() + "'/>";
Please be detailed in how I can fix this problem!
Thanks!
EDIT: I have come across some stuff about an Image Servlet? Any ideas?