Results 1 to 5 of 5
- 04-20-2012, 12:49 PM #1
Member
- Join Date
- Mar 2011
- Posts
- 30
- Rep Power
- 0
Upload file in jsp and save it to MYSQL
I am trying to upload file in jsp.
I used HTML file tag
<input type="file" name="resume" size="20" value="Upload Resume ">
then in second page I retrieved its value by String filepath=request.getParameter("resume");
But its only giving the file name not the file path.Please someone tell me how i can read file by this and how it can be stored in mysql.
Thanx in advance!!
- 04-20-2012, 01:14 PM #2
Re: Upload file in jsp and save it to MYSQL
Moved from Advanced Java
dbWhy do they call it rush hour when nothing moves? - Robin Williams
- 04-20-2012, 01:27 PM #3
Moderator
- Join Date
- Apr 2009
- Posts
- 10,484
- Rep Power
- 16
Re: Upload file in jsp and save it to MYSQL
You'll want something like Apache FileUpload.
That'll handle the multipart bit which gives you access to the file stream.Please do not ask for code as refusal often offends.
- 04-20-2012, 08:34 PM #4
Member
- Join Date
- Apr 2012
- Posts
- 2
- Rep Power
- 0
Re: Upload file in jsp and save it to MYSQL
<html>
<head>
<title>File Uploading Form</title>
</head>
<body>
<h3>File Upload:</h3>
Select a file to upload: <br />
<form action="UploadServlet" method="post"
enctype="multipart/form-data">
<input type="file" name="resume" size="50" />
<br />
<input type="submit" value="Upload File" />
</form>
</body>
</html>
-----------
Servlet part
------------
DataInputStream in = new DataInputStream(request.
getInputStream());
//we are taking the length of Content type data
int formDataLength = request.getContentLength();
byte dataBytes[] = new byte[formDataLength];
int byteRead = 0;
int totalBytesRead = 0;
//this loop converting the uploaded file into byte code
while (totalBytesRead < formDataLength) {
byteRead = in.read(dataBytes, totalBytesRead,
formDataLength);
totalBytesRead += byteRead;
}
String file = new String(dataBytes);
//for saving the file name
Hope then u ll find how to update in DB
- 05-03-2012, 07:38 AM #5
Member
- Join Date
- Mar 2011
- Posts
- 30
- Rep Power
- 0
Similar Threads
-
How to save finger print template created by Digital Persona into mysql database
By Riaz Ali in forum JDBCReplies: 3Last Post: 03-12-2012, 02:03 PM -
upload and save file
By chennee72 in forum JavaServer Pages (JSP) and JSTLReplies: 4Last Post: 06-29-2011, 02:27 PM -
How to upload .txt file to mysql using JDBC
By sks in forum JDBCReplies: 2Last Post: 04-05-2011, 10:19 AM -
How to show or open a file download or file save dialog box
By java_bond in forum New To JavaReplies: 0Last Post: 03-05-2010, 04:21 AM -
:large file upload to server(chunk upload)
By tommy_725 in forum NetworkingReplies: 0Last Post: 10-16-2009, 12:21 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks