Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > J2EE
|
J2EE General J2EE (Java 2 Enterprise Edition) discussions. Questions not specific to EE will be redirected elsewhere.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the J2EE section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 17th, 2008, 09:16 AM
Authorized User
 
Join Date: Jan 2008
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default File uploading from local syste in web application

Hi,

I am trying to insert a file from my local system into the database using a web application. The application is running on a remote server.

The problem is my application on the server is not able to get the file from my local system.

Can any one help how to solve this problem.

Regards
__________________
Regards
 
Old July 22nd, 2008, 06:07 AM
Friend of Wrox
 
Join Date: Mar 2007
Posts: 373
Thanks: 0
Thanked 1 Time in 1 Post
Default

Little more info about how you implemented and what error you are getting will help us solve your problem.

- Rakesh
 
Old July 30th, 2008, 01:54 PM
Registered User
 
Join Date: Jul 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Try FileI/O inside the service/doXXX methods like below.


//process the action
 conn = getConnection();
      conn.setAutoCommit(false);
      File file = new File(fileName);
      fir = new FileReader(file);
      pstmt = conn.prepareStatement("insert into DataFiles(id, fileName, fileBody) values (?, ?, ?)");
      pstmt.setString(1, id);
      pstmt.setString(2, fileName);
      pstmt.setAsciiStream(3, fis, (int) file.length());
      pstmt.executeUpdate();
      conn.commit();


}





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to Open a PDF file in a web application zaghmout ASP.NET 2.0 Professional 2 September 19th, 2008 12:53 PM
How to add icon file for a web application?? noblez ASP.NET 1.0 and 1.1 Professional 3 April 24th, 2007 02:21 AM
How can i make .net web application as an exe file kesakiran ASP.NET 1.0 and 1.1 Professional 1 December 11th, 2006 09:44 AM
Web Config File for uploading to SQLExpress SoftMind BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 4 August 31st, 2006 10:11 PM
running .exe file in web application exactlynn General .NET 0 May 5th, 2004 11:54 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.