Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Uploading CV .doc to MySql database

Options
  • 01-06-2012 3:52pm
    #1
    Closed Accounts Posts: 82 ✭✭


    Hi,
    Anybody have suggestions on how to upload a document in Java to MySql database.I understand I should be using MEDIUMBLOB is this the correct content type!? I also would be grateful if somebody could suggest a way to implement the method to upload it?
    Thanks


Comments

  • Registered Users Posts: 10,624 ✭✭✭✭28064212


    Do you need to? Could you not just upload the document to the filesystem, then store the path in the database?

    Boardsie Enhancement Suite - a browser extension to make using Boards on desktop a better experience (includes full-width display, keyboard shortcuts, dark mode, and more). Now available through your browser's extension store.

    Firefox: https://addons.mozilla.org/addon/boardsie-enhancement-suite/

    Chrome/Edge/Opera: https://chromewebstore.google.com/detail/boardsie-enhancement-suit/bbgnmnfagihoohjkofdnofcfmkpdmmce



  • Registered Users Posts: 1,082 ✭✭✭Feathers


    28064212 wrote: »
    Do you need to? Could you not just upload the document to the filesystem, then store the path in the database?

    OP, generally this would give you faster queries vs the database/access to the document & useless you've a good reason not to do this, it's probably the best way to go.


  • Closed Accounts Posts: 82 ✭✭lippy88


    I have very little experience with doing that how do I direct it to the path?? Any examples would help a lot!:)


  • Registered Users Posts: 1,082 ✭✭✭Feathers


    lippy88 wrote: »
    I have very little experience with doing that how do I direct it to the path?? Any examples would help a lot!:)

    Well rather than storing the Word file in the database, you'd upload it to the filesystem — e.g. at "/public_html/docs/lippy_cv.doc". Then rather than trying to input the file into the DB, you'd have a data type of varchar or char & pass the string of the path in, storing that path to the database instead.

    So for instance, if you're uploading a file from a form, handling the form input via PHP. You're PHP code would be responsible for setting a filename & writing the file to the file-system. Then it would take the same filename you've written & insert it into the database, along with any other data from the form.

    When taking data out of the DB, if you wanted to provide a list of files matching a search for example, you'd get back string data from the database rather than the file itself, but then in your code you'd simply point it at the path from the database. Do that answer your question…?

    If not maybe give a bit more detail for your sample case.


  • Closed Accounts Posts: 82 ✭✭lippy88


    Ok so what Im trying to do is upload the CV when the user registers with the job agency.This upload CV box would be uploaded when they are given all their other details.Here is the JSP page for the register page.
    <s:form action="register.action" method="post">

    <table width="100%" border="0" cellpadding="3px" class="htmlForm" cellspacing="0">
    <tr>
    <td colspan="2"> </td>
    </tr>
    <tr>
    <s:textfield name="username" label="Username" size="40" />
    </tr>
    <tr>
    <s:textfield name="password" label="Password" size="40" />
    </tr>
    <tr>
    <s:textfield name="fname" label="First Name" size="40" />
    </tr>
    <tr>
    <s:textfield name="lname" label="Surname" size="40" />
    </tr>
    <tr>
    <s:textfield name="address" label="Address" size="40" />
    </tr>
    <tr>
    <s:textfield name="city" label="City" size="40" />
    </tr>
    <tr>
    <s:textfield name="country" label="Country" size="40" />
    </tr>
    <tr>
    <s:textfield name="mobilephone" label="Mobile" size="40" />
    </tr>
    <tr>
    <s:textfield name="homephone" label="HomePhone" size="40" />

    </tr>
    <tr>
    <s:textfield name="email" label="Email" size="40" />

    </tr>

    ##########UPLOAD CV HERE###################

    <s:submit />
    </s:form>

    </table>


    I am using Java with struts so in the register.action class I would like to know the code to insert this into the database.I have never done this before and really have no clue how to go about it.I could only find tutorials for PHP online and wasnt able to understand that!!
    My big problem is trying to follow what you have advised...writing it to the filesystem! Thanks for your help:)


  • Advertisement
Advertisement