This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Servlets and the fly likes Upload file or pdf in database with its extension in separate column Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Upload file or pdf in database with its extension in separate column" Watch "Upload file or pdf in database with its extension in separate column" New topic
Author

Upload file or pdf in database with its extension in separate column

Madhuri Abhi
Greenhorn

Joined: Jun 29, 2011
Posts: 11
Hi all

I want to upload either image or pdf or doc files(etc) in database with its extension.
Say suppose if i upload an text file, its extension .txt should be stored in one of the columns. How can i do that?

Thanks,
Madhuri.


Sudheer Bhat
Ranch Hand

Joined: Feb 22, 2011
Posts: 75
store the file as BLOB and the extension as varchar column in the table? You just need to strip off the extension and store it in the varchar column. Not really sure why you want to store the file extension though.
Madhuri Abhi
Greenhorn

Joined: Jun 29, 2011
Posts: 11
I am able to store files in the database. The fields in the database are id, name( of the file as varchar), type(file extension as varchar) and content(as blob).

While retrieving from database, i want to display just the id, name and extension in jsp page in table form. That can be done very easily.

But what i want to do is when the name(that is displayed) is clicked, the file should open. any idea on how i can do that.

Madhan Sundararajan Devaki
Ranch Hand

Joined: Mar 18, 2011
Posts: 312

Include an URL to the file and the browser should automatically show you the file open/download box etc...


S.D. MADHAN
Not many get the right opportunity !
Juanjo Cuadrado
Greenhorn

Joined: Jun 27, 2011
Posts: 18

Hi,

Your cuestion I think is about servlet, not JDBC.

If you want to open file doing click over a link, you have to have a servlet, and in the get (or post) method put this code (or another similar):



I hope this help you...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Upload file or pdf in database with its extension in separate column
 
Similar Threads
Document Retrival from database.
how do I take out the extension in javascript :( urgent ....
Upload pdf file to mysql database
FileUpload Word,PDF, Excel Files
uploading a file but want to restrict the type of files