Ask a Question related to Macromedia Flex General Discussion, Design and Development.
-
Suren_kancherla #1
store/retrieve images to server
Hi All,
I want to retrieve images from server and send them back to Servlet without using FileUpload. It's an urgent requirement please help me out.
Thanks in Advance.
Surendra.
Suren_kancherla Guest
-
unable to retrieve or display images from sql database
Using Dreamweaver 8 and connecting to an Sql Server 2000 i am not able to display image files from the sql table. the other fields in the table are... -
store and retrieve flash in and from database
Hi all, i stored an uploaded flash-file in a MS-SQL database. Now i want to retrieve this file from my database in ASP.NET, but I don't know how to... -
How to store objects in array and the retrieve them
Hi, I'm trying to store objects in an array and then later I want to retrieve the object again. I tried it the following way, but it doesn't... -
Storing Images in SQL Server - ASP storage and retrieve
I need some help, because I am utterly confused with how to do this. I have 2 things that I need to figure out, and could use some sample code or... -
How to store Images in SQL Table
Define a column as image and just send the data to the image to this column as normal, usually as a byte array. See also the thread 'Why should I... -
klakiers #2
Re: store/retrieve images to server
This is not better solution. I encode image with base64 and send to servlet. In
servlet i decode image to byte array and save to server.
I would now better solution too.
We have to waiting for someone who know more ... :)
Flex:
private function uploadImage():void {
var params:Object = { fileName: _fileRef.name ,
fileData: getBase64String(imgComponent)};
myHttpService.send();
}
private function getBase64String(component:UIComponent):String {
var bitmapData:BitmapData = new BitmapData(component.width, component.height,
true, 0xffffff);
bitmapData.draw(component);
var encoder:IImageEncoder;
// jpg, *.jpeg, *.gif, *.png
if (_fileRef.type.toLowerCase() == 'jpg' || _fileRef.type.toLowerCase() ==
'jpeg') {
encoder = new JPEGEncoder(80);
} else {
encoder = new PNGEncoder();
}
var bytes:ByteArray = encoder.encode(bitmapData);
var b64encoder:Base64Encoder = new Base64Encoder();
b64encoder.encodeBytes(bytes);
var b64String:String = b64encoder.flush();
return b64String;
}
Java:
import sun.misc.BASE64Decoder;
import java.io.*;
...
String UPLOAD_DOMAIN = "/MyUploadPath/";
String fileName = request.getParameter("fileName");
try {
if (fileName != null) {
BASE64Decoder base64 = new BASE64Decoder();
// Decode base64 to byte array
byte[] decodedData =
base64.decodeBuffer(request.getParameter("fileData ").toString());
// Save on server
FileOutputStream fos = new FileOutputStream(UPLOAD_DOMAIN+fileName);
fos.write(decodedData);
fos.close();
} else {
System.out.println("ImageCutUpload (failed): file name is empty.");
}
} catch( IOException e ){
System.out.println("ImageCutUpload (failed): write error: "+e);
}
klakiers Guest



Reply With Quote

