cancel
Showing results for 
Search instead for 
Did you mean: 

image uploading and saving to database

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi kavita,

Do u want to do this with webdynpro java?? If yes u can go for a simple solution explained here : <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/00062266-3aa9-2910-d485-f1088c3a4d71">Uploading/Downloading files</a>

U can get the sample application here

<a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/sdn/webdynpro?rid=/library/uuid/49f2ea90-0201-0010-ce8e-de18b94aee2d#41">https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/sdn/webdynpro?rid=/library/uuid/49f2ea90-0201-0010-ce8e-de18b94aee2d#41</a>

regards

Sumit

Former Member
0 Kudos

Yes ,

I am using web dynpro java. But if i want to pass that image to ejb module through webservbice , n that ejb will insert image into table created in dictionary DC using entity bean. then in this case wt will data type of node accepting image in ejb??

Former Member
0 Kudos

Hi,

In WD use IWDResource as the data type

Your webservice should be supporting soap with attachments.

In EJB you can use the get?setBytes to write back them to Db.

regards

ayyapparaj

Former Member
0 Kudos

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

Former Member
0 Kudos

In database it is stored as BLOB . what is BLOB . Is it i have to create field in table having type BLOB or something else???

Kavita

Former Member
0 Kudos

Hi Kavita,

BLOB is Binary large Object. In ur db table, u can have to create it as BLOB. for further details u can check here

<a href="http://java.sun.com/j2se/1.4.2/docs/api/java/sql/Blob.html">http://java.sun.com/j2se/1.4.2/docs/api/java/sql/Blob.html</a>

u can find sample code here

<a href="http://www.jguru.com/faq/view.jsp?EID=1325">http://www.jguru.com/faq/view.jsp?EID=1325</a>

regards

Sumit

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

Pl check this blog

/people/anilkumar.vippagunta2/blog/2007/02/20/reading-and-writing-images-from-sqlserver-in-webdynpro

Regards

Ayyapparaj