on 11-19-2007 9:54 AM
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
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
Hi,
Pl check this blog
/people/anilkumar.vippagunta2/blog/2007/02/20/reading-and-writing-images-from-sqlserver-in-webdynpro
Regards
Ayyapparaj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
24 | |
11 | |
9 | |
7 | |
6 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.