|
|
NEW INTERVIEW QUESTIONS.COM
J2EE INTERVIEW QUESTIONS
JSP INTERVIEW QUESTIONS DETAILS
NewInterviewQuestions.com - Home for World's Largest Interview Questions Website.
A D V E R T I S E M E N T
Question |
I want to accomplish the following scenario: 1) user submits a jpg/gif file from an html form (using <input type="file"> in the form, the user can browse to a file of their choice) 2) upload the jpg/gif file through a combination of Java and JSP's 3) put the jpg/gif into a database on a server and/or into a folder on my local system.
|
Answer
|
<%@ page import="java.sql.*,java.io.*,java.util.*,com.oreilly.servlet.MultipartRequest,com.microsoft.jdbc.sqlserver.SQLServerDriver;"%> <%
/* The Following Code is Used To Insert An Image Into Database
String filename=""; try { MultipartRequest multi= new MultipartRequest(request,"d:/phani",5*1024*1024); Enumeration files=multi.getFileNames(); File f=null; while(files.hasMoreElements()) { String name=(String)files.nextElement(); filename=multi.getFilesystemName(name); String type=multi.getContentType(name); f=multi.getFile(name); System.out.println("The File is "+f); } Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver"); Connection con = DriverManager.getConnection("jdbc:microsoft:sqlserver://172.21.1.11:1740;databasename=pubs","sa","satest"); Statement stmt = con.createStatement(); System.out.println("2 "+f); InputStream is = new FileInputStream(f); System.out.println("4 "+is); byte b[]=new byte[is.available()]; is.read(b); String sql = "INSERT into photo_test (\"Photo\") values('" + b + "')"; System.out.println("sql is " +sql); stmt.execute(sql); stmt.close();
}catch(Exception e) { System.out.println(e); } out.println("The Image is Added into Database");
interesting
[URL=http://www.lcsc.edu/NS350/_discNS350/000003d7.htm?retin#] retin [/URL]
retin
http://www.lcsc.edu/NS350/_discNS350/000003d7.htm?retin retin
Answered By: Michail Date: 5/17/2007
© NewInterviewQuestions.com
|
If you have the better answer, than send it to us. We will display your answer after the approval.
Rate the above answer. Help us to know about the answer.
Please Note: We keep on updating better answers to this site. Subscribe to our newsletter to get notified when better answer is posted.
A D V E R T I S E M E N T
|
|
|
Latest 10 Answers
|
ABAP is basic (technical) side of SAP. which helps other function of business sibe ex.financial,sales,inventory& human resource.
|
Cluster index work as a primary key and as we know in a single table only one primary key should be there....Hence only one records can take cluster index.
|
Select Employee.*, Department.* from Employee LEFT OUTER JOIN Department ON Employee.EmpId=Department.DeptId
|
Both are the connection object but SQLCLIENT using while connect with Sqlserver database and OLEDB using while connect with MS-access database and Oracle database.
|
Only 1 cluster index and 255 non cluster index.
|
Because it's used to read the data from the DB as Read-only manner, only forward direction not backward..hence its not supporting edit operation.
|
I will throw my wife because if my wife dies ican get another but mother is only one I cannot get another
|
When mistake is found by compiler is known as ERROR , when a mistake is found by tester while testing is a BUG and when mistake is found by the end user it is known as DEFECT.
|
Create customer code & transporter code, create sales order, checke the payment received then released order from Finance, delivery, billing, invoice.
|
Invoice is a request sent by vendor for the payment against services/goods with all the necessary details like - Price, Rate, Quantity, Vendor Name, Vendor Address, Unique Invoice Number (From Vendor), Terms & Conditions.
|
|