Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8572481
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T19:01:17+00:00 2026-06-11T19:01:17+00:00

I want to upload the files into mysql database using jsp.When i use input

  • 0

I want to upload the files into mysql database using jsp.When i use input type=”file”, jsp is not returning full path. i need full path to upload a file in mysql db.

<form id="translationFormID" method="post" action="saveTranslation">

<input type="file" name="attachCV" id="attachCVID" value="Attach CV">

<input type="submit" name="submit" />

</form>

This is my jsp page. i calling the servlet ‘saveTranslation’ using post method.

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    String attachCV=null;
    try{
        String attachCV=request.getParameter("attachCV");
        System.out.println("path= "+attachCV);
    }
    catch(Exception){
        e.printStackTrace();
    }
}

This is my servlet code. here getting and printing attachCV parameter. when i print the attachCV, its showing something like ‘c:\fakepath\sample.docx’

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T19:01:18+00:00Added an answer on June 11, 2026 at 7:01 pm

    i need full path to upload a file in mysql db.

    There’s a major thinking mistake here.

    Imagine that I am the client who want to upload the file and that you are the server who need to get the file’s contents. I give you my full local disk file system path c:\path\to\sample.docx as the sole information, exactly as you requested. How would you as being the server ever get its contents? Do you have an open TCP/IP connection to my local hard disk file system? Really?

    This isn’t how uploading files works. This would only ever work if the server runs at physically the same machine as the client, so that you can just use FileInputStream with that path. This would thus only ever work in the local development environment, but definitely not in real world production where the server runs at a physically different machine than the client, separated by a HTTP connection.

    You should instead be interested in the sole file contents which the client has sent to you along with the HTTP request body. In HTML terms, you can use <input type="file"> for this in a <form enctype="multipart/form-data">. A more detailed answer with full code examples can be found here: How to upload files to server using JSP/Servlet? It describes the modern Servlet 3.0 way using request.getPart() and the previously defacto standard Apache Commons FileUpload API.

    Once you’ve implemented it the right way, you should ultimately end up with an InputStream representing the file contents which you obtained from the Servlet 3.0 part.getInputStream() or the Apache Commons FileUpload item.getInputStream(). You can then just use PreparedStatement#setBinaryStream() the usual way to store it in the DB and ResultSet#getBinaryStream() to retrieve it from the DB.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to upload an image file into mysql database on Android Mobile Programming,
I want to insert data from excel file to MySQL database using JSP. once
I can easily upload the files into the database But when i want to
I want to upload a csv file into a sql table. Here is my
I want to upload files directly to IIS7 (in this case I am using
I am using PHP to upload a file and then I want to grab
I want to insert files into mysql from php function. The files that need
I want to upload a large file of maximum size 10MB to my MySQL
I want to store image on mysql database by php as blob type, but
I am using the following script to upload records to my MYSQL database, the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.