Hi nataraj,
Hope this code helps you...

Here is the Jsp code

<!-- upload.jsp -->
<%@ page import="java.io.*" %>
<%
String contentType = request.getContentType();
DataInputStream in = new DataInputStream(request.getInputStream());
int formDataLength = request.getContentLength();
byte dataBytes[] = new byte[formDataLength];
int byteRead = 0;
int totalBytesRead = 0;
while (totalBytesRead < formDataLength)
{
byteRead = in.read(dataBytes, totalBytesRead, formDataLength);
totalBytesRead += byteRead;

}
String file = new String(dataBytes);
String saveFile ="image1.png";
saveFile = "path-name" + saveFile;
FileOutputStream fileOut = new FileOutputStream(saveFile);
fileOut.write(dataBytes);
fileOut.flush();
fileOut.close();
%>


Here is the Flex code....


             var _url:URLLoader=new URLLoader()

             strURL='/../blazeds/Upload/image1.png'
             var imagefilter:FileFilter=new
FileFilter("Images(*.png)","*.png" );
             var _imagearray:Array=new Array(imagefilter)
             bitmapData=new
BitmapData(myDisplay.dContainer.width,myDisplay.dContainer.height)
            bitmapData.draw(myDisplay.dContainer);
            bytearray = PNG.encode(bitmapData)
            fileRef=new FileReference()
            try
            {
             req = new
URLRequest('/../blazeds/EquationEditorafterdemo-debug/ServerJsp/file2.jsp');

             req.method = URLRequestMethod.POST;
             req.data = bytearray;
             req.contentType="application/octet-stream";
             _url.load(req);

             req= new URLRequest(strURL);

             req.method = URLRequestMethod.GET;
             fileRef.download(req)


This flex code just passes the bytearray to the JSP code.. which will open a
file named image1.png and store the byte array and put the file in the
path-name....Hope you get it... If ur not clear reply me back...

Cheers
Satish
On Mon, Nov 10, 2008 at 8:36 PM, natarajan santosh
<[EMAIL PROTECTED]>wrote:

> Hi friends,
>
> I need code for uploading an image in flex without PHP or other languages
> Help me
>
> Regards
> Natarajan V
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Flex 
India Community" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/flex_india?hl=en
-~----------~----~----~----~------~----~------~--~---

  • ... natarajan santosh
    • ... Satish பேர கேட்டா சும்மா அதுருதில
      • ... Vinod M. Jacob
        • ... kiet tuan

Reply via email to