Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

image uploading and saving to database

hi ,

I am developing application for summer placement . i want to upload image with candidate's details and save it to database. How to do this? I hv got tutorials for uploading image but want to know how to save it to database table along with candidate's details.

Kavita

Former Member
Former Member replied

Hi kavita,

In Webdynpro u r using attribute of type Resource ,which is binded to FileUpload UI element. From this attribute, u get file in Input stream format which can be converted into byte array like this

byte fileData[] = null;

try{

InputStream fileIs = wdContext.currentFile().getFileData().read(false);

ByteArrayOutputStream bOut = new ByteArrayOutputStream();

int length;

byte[] part = new byte[10 * 1024];

while ((length = fileIs.read(part)) != -1) {

bOut.write(part, 0, length);

}

fileIs.close();

fileData = bOut.toByteArray();

bOut.close();

} catch (Exception e) {

wdComponentAPI.getMessageManager().reportSuccess(e.toString());

}

In webservice u can take a the byte array as input parameter where the uploaded file will be passed as byte array .

In DB u can store it as BLOB .

in case of any other doubt u can revert back to me.

regards

Sumit

0 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question