Go Back   Velocity Reviews > General Computer Discussion > Software
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread
Old 05-21-2008, 12:02 PM   #1
Exclamation Cannot Upload file from Local Machine


Hi,
I'm facing a problem while trying to upload an image from local machine hard drive to the database in web server using servlet.
I'm able to upload an image to the database in the local machine !!!!!!
But the image is not being uploaded to the remote database !!
The String CouponImage is a local machine path of the image like E:\Coupons\Coupon1.jpg . It's not being accepted.
Please help me. I'm new to servlet programming.
I'm using the following code

public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
{
res.setContentType("text/html");
try{
Connection connection = null;
FileInputStream fis = null;
PreparedStatement preparedStatement =null;
Class.forName("com.mysql.jdbc.Driver").newInstance ();
connection = DriverManager.getConnection ("jdbc:mysql://localhost/MobileCoupons",username,password);
String CouponImage = req.getParameter("upload");
String query = "INSERT INTO Coupondata(CouponImage) VALUES (?)";
preparedStatement = connection.prepareStatement(query);
File file = new File(CouponImage);
fis = new FileInputStream(file);
preparedStatement.setBinaryStream(3, fis, (int) file.length());
preparedStatement.execute();
connection.commit();
connection.close();
fis.close();
}
}


apjustin
apjustin is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
File transfer program for local machine to application server. Jagadeeshg Software 0 03-02-2009 09:51 AM
Upload image thumbnail to Web Server ? Problem... tapasmahata Software 0 02-07-2008 10:03 AM
pcAnywhere and Brother fax machine on same phoen line bem522 Software 0 07-20-2007 04:20 PM
Re: Can't login to XP Pro machine jjw A+ Certification 2 10-19-2004 12:36 AM
Re: Can't login to XP Pro machine Gary A+ Certification 3 09-22-2004 10:17 PM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46