The critical part is to set enctype to multipart/form-data in the HTML form:

<form method="post" enctype="multipart/form-data" 
action="$link.setPage("UploadImage.vm").setAction("UploadImage")">

The rest should work as you have below.

David


-----Original Message-----
From: Albrecht Leiprecht [mailto:[EMAIL PROTECTED] 
Sent: Monday November 15, 2004 12:17 PM
To: Turbine Users List
Subject: How to upload Images


Hi all,

I understand that

   FileItem fileItem = data.getParameters().getFileItem("file");
   fileItem.write(TurbineServlet.getRealPath("") +"/images/" +
data.getUser().getUserName() + ".jpg");

is supposed to be used for uploading content through forms in Turbine
actions.
It seems to work, with one little problem.... The image I am getting on the
server is
totally scrambled. Doesnt look like the original at all.

The above example works fine with textfiles __ignore the *jpg ;) __
I assume that i woul have to fiddle with the content type somewhere. But the
question is where and how...

Does anyone have an idea ??

kind regards
Albrecht F. Leiprecht


PS:
I am using Turbine 2.1 on Tomcat 4


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to