0

I have a Struts2 jsp page their i am sending one image, Temporary file path is comming to my java class after form submission but i do not know how can to save that path in db by changing it to Blob type.. Please consider this image columns is of blob type in my database table..

Here is the output what am getting in my Javaclass after the form submission:

My image path:

F:\Documents and Settings\software.netbeans\7.0\apache-tomcat-7.0.11_base\work\Catalina\localhost\AIGSA\upload__214d4f3e_136e8b74d9c__7fff_00000021.tmp 105542

filenames: * Winter.jpg

Code:

for (File u: repImage) 
{
    System.out.println("*** "+u+"\t"+u.length());
}

int saveToDb= mo.addMembers(memberName, repImage);

How can I send my form Image to this {repImage Name, so that it will be easy to save it so my db

2 Answers 2

0

am not sure, but try:

int saveToDb= mo.addMembers( memberName, repImage.getBytes() );
1
  • not it is not supporting. I have define repImage as private File[] repImage; ...having getter setter
    – Dan
    Apr 25, 2012 at 9:23
0

If I understand your question properly, you want to store the binary data in your database. I'd say this is a bad idea in the first place for multiple reasons. A better method would be to reference a relative path that you can then use in your web application or the file system directly. Better yet, just store the reference to the location in Amazon/S3 where you want to save it/use it.

Regardless, to answer your question you would want to use ByteArrayOutputStream.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.