How can upload doc file into database !!

Dear Everyone,
How can i upload a doc file into Mysql database ....
can any one please give ur suggestions...
i will show u my code
upload.jsp
<form name="uploader" action="uploaded.jsp"
enctype="multipart/form-data">
  <div align="center">
  <table id="table1" border="1" bordercolor="#ff0000"
cellpadding="0" cellspacing="0" width="50%">
    <tbody bgcolor="#c8d8f8">
      <tr>
        <td bgcolor="#ccccff">
        <p align="center">
           Resume Upload! </p>
        </td>
      </tr>
      <tr>
        <td> 
        <p align="center">You can upload your
resume.. </p>
        <p align="center">
        <table align="center" border="1"
cellpadding="10" cellspacing="10">
          <tbody>
            <tr>
              <td>
              <p><input name="file" type="file">
              <input name="uploadButton" value="Upload"
type="submit"></p>
              </td>
            </tr>
          </tbody>
        </table>
        </p>
        </td>
      </tr>
    </tbody>
  </table>
  </div>
</form>
uploaded.jsp
<BODY>
<%@ page import="java.sql.*" %>
<%@ page import="java.util.*" %>
<%@ page import="java.io.*" %>
<% 
    String file1=request.getParameter("file");
    int len;
    String query;
    PreparedStatement pstmt;
   int i=0;
    Class.forName("com.mysql.jdbc.Driver");
DriverManager.getConnection("jdbc:mysql://localhost:3306    Connection conn= /employee","root","");
     try {
            File file = new File(file1);
               if (file==null)
%>
<center>Nothing in It</center>
<%
            else
            FileInputStream fis = new FileInputStream(file);
            len = (int)file.length();
            query = ("insert into loader(resume) VALUES(?)");
            pstmt = conn.prepareStatement(query);
            pstmt.setString(1,file.getName());
            pstmt.setInt(2, len);
            //method to insert a stream of bytes
            pstmt.setBinaryStream(3, fis, len);
          i=pstmt.executeUpdate();
               if(pstmt!=null)
             pstmt.close();
            if(conn!=null)
             conn.close();
        } catch (Exception e) {
            e.printStackTrace();
             if(i>0)
                    out.println("uploaded");
                else
                    out.println("not uploaded")
%>
</BODY>

File file = new File("myDoc.doc");
FileInputStream fis = new FileInputStream(file);The file name will most likely NOT be hard-coded. I don't think the question surrounding this topic is how to do the insert statement (he/she clearly knows SQL).
HTTP and the web browser take care of the file transfer, but the server stores the file in a temporary location. The question is, "How do I found out that location?" In PHP (I know that doesn't offer much help to you, but ...), that location is held in a variable called $_FILES. From there you can simply copy the file to a location you specify (probably with a user-specified name under a directory specifically for that user).
I hope this is of some help:
http://www.oop-reserch.com/mime_example_4.html
Good Luck,
C. R.

Similar Messages

  • How can i load file into database from client-side to server-side

    i want to upload file from client-side to server-side, i use the following code to load blob into database.
    if the file is in the server-side, it can work, but if it in the client-side, it said that the system cannot find the file. i think it only will search the file is in the server-side or not, it will not search the client-side.
    how can i solve it without upload the file to the server first, then load it into database??
    try
    ResultSet rset = null;
    PreparedStatement pstmt =
    conn.prepareStatement ("insert into docs values (? , EMPTY_BLOB())");
    pstmt.setInt (1, docId);
    pstmt.execute ();
    // Open the destination blob:
    pstmt.setInt (1, docId);
    rset = pstmt.executeQuery (
    "SELECT content FROM docs WHERE id = ? FOR UPDATE");
    BLOB dest_lob = null;
    if (rset.next()) {
    dest_lob = ((OracleResultSet)rset).getBLOB (1);
    // Declare a file handler for the input file
    File binaryFile = new File (fileName);
    FileInputStream istream = new FileInputStream (binaryFile);
    // Create an OutputStram object to write the BLOB as a stream
    OutputStream ostream = dest_lob.getBinaryOutputStream();
    // Create a tempory buffer
    byte[] buffer = new byte[1024];
    int length = 0;
    // Use the read() method to read the file to the byte
    // array buffer, then use the write() method to write it to
    // the BLOB.
    while ((length = istream.read(buffer)) != -1)
    ostream.write(buffer, 0, length);
    pstmt.close();
    // Close all streams and file handles:
    istream.close();
    ostream.flush();
    ostream.close();
    //dest_lob.close();
    // Commit the transaction:
    conn.commit();
    conn.close();
    } catch (SQLException e) {

    Hi,
    Without some more details of the configuration, its difficult to know
    what's happening here. For example, what do you mean by client side
    and server side, and where are you running the upload Java application?
    If you always run the application on the database server system, but can't
    open the file on a different machine, then it sounds like a file protection
    problem that isn't really connected with the database at all. That is to
    say, if the new FileInputStream (binaryFile) statement fails, then its not
    really a database problem, but a file protection issue. On the other hand,
    I can't explain what's happening if you run the program on the same machine
    as the document file (client machine), but you can't write the data to the
    server, assuming the JDBC connection string is set correctly to connect to
    the appropriate database server.
    If you can provide some more information, we'll try to help.
    Simon
    null

  • How to upload binary file in database?

    Using servlets..how to upload binary file into database...
    How to get the data of file in servlet...
    Please reply...i'm unable to find exact code...that i want..

    You need to do two separate parts: accept the file from a HTTP multi-part POST and then stream it into a BLOB on the database. To do the former, download Jakarta Commons FileUpload. There is extensive documentation on how to write a simple handler for the upload. You then need to send the data to a BLOB. The specifics vary from database to database but generally you will insert or update a row with an empty blob, get a reference to the blob, pipe the data and then commit.
    If you do a quick forum search, this question has been asked (and answered) dozens of times. Some of the replies may even have code for you. Best of luck.
    - Saish

  • How to convert Doc file into image

    hello frnds
                     Can any body guide me how to convert doc file into image and show into swf loader.
    actually i have to convert doc files into swf files in runtime so that i have to use this flow.
    is it possible to convert doc file into byte array and than convert into image.
    Thanks And Regards
        Vineet Osho

    You can convert any DisplayObject to byeArray using this function ImageSnapshot.captureBitmapData().getPixels()

  • How to upload a file to database in Apex 4.2.2?

    How to upload a file to database in Apex 4.2.2 in Existing Application? Also How to view the uploaded file within this application?
    Any help to his question is very appreciated?
    Thanks,
    Prak.

    980835 wrote:
    Please update your forum profile with a real handle instead of "980835".
    Actually we want to upload the file to our own table and retrive from it as well. Is it possible to see the file of person whom we are pulling?
    This is covered in the documentation: About BLOB Support in Forms and Reports. There's also a tutorial in the Oracle Learning Library.

  • How to upload a file into a db blob column from adf page

    How to upload a file into a db blob column from adf page
    Which option to use ?

    The forum search would be my first try...
    Then google...
    This has been asked at least once a week and got correct answers...
    Timo

  • How to upload a file into server using j2ee jsp and servlet with bean?

    How to upload a file into server using j2ee jsp and servlet with bean? Please give me the reference or url about how to do that. If related to struts is more suitable.
    Anyone help me please!

    u don't need j2ee and struts to do file uploading. An example is as such
    in JSP. u use the <input> file tag like
    <input type="file"....>You need a bean to capture the file contents like
    class FileUploadObj {
        private FormFile srcFile;
        private byte[] fileContent;
        // all the getter and setter methods
    }Then in the servlet, you process the file for uploading
        * The following loads the uploaded binary data into a byte Array.
        FileUploadObj form = new FileUploadObj();
        byte[] byteArr = null;
        if (form.signFile != null) {
            int filesize = form.srcFile.getFileSize();
            byteArr = new byte[filesize];
            ByteArrayInputStream bytein = new ByteArrayInputStream (form.srcFile.getFileData());
            bytein.read(byteArr);
            bytein.close();
            form.setFileContent(byteArr);
        // Write file content using Writer class into the destination file in the server.
        ...

  • Hi, I am user iPad and I do not know how can attach a file into email e.g. CV.  Thanks

    Hi,
    I am user iPad and I do not know how can attach a file into email e.g. CV. 
    Thanks

    You attach files within the app that creates the file or within the app that the file is saved. For example you email photos from within  the Photos App itself. Typically there will be an action icon within the app - an arrow icon many times - you tap on that to bring other options like Share - then Email.
    Attachments must be mailed within the apps themselves.

  • How to change music in uc320?how to upload mp3 file into uc320?

    Dear all,
    how to change music in uc320?only one music in uc320?
    how to upload mp3 file into uc320?
    Thanks
    John

    I am evaluating the UC320 for a phone system replacement for our 100 locations.
    Allowing us to add an MP3 file to replace the current one would be a HUGE cost savings.
    This will help us cut cost when compared to the old system.
    Currently we are spending $180 on an external mp3 player for an mp3 that’s 3MB in size.
    If this system works out we are then going to recommend it to our 1800 franchisees.

  • How to batch upload PDF files into database BLOB

    Hello.
    I have a requirement to batch upload PDF files into BLOB column of an Oracle 8.1.7 table from Forms 6i Web. The content of the blob column (ie. the PDF content) MUST be displayable from all client software (eg. Oracle Web forms, HTML forms, etc.)
    Our environment is
    Middle-tier is 9iAS on Windows/2000
    Database is Oracle 8.1.7.0.0 on VMS
    Oracle Web Forms 6i Patch 10
    Basically my Oracle web form program will display a list of PDF files to upload and then the user can click on the &lt;Upload&gt; button to do the batch upload. I have experimented the following approaches but with no luck.
    1. READ_IMAGE_FILE forms built-in = does NOT work because it cannot read PDF file. I got error FRM-47100: Cannot read image file
    2. OCX and OLE form item = cannot use this because it does NOT work on the Web. I got error FRM-41344 OLE object not defined
    3. I cannot use DBMS_LOB to do the load because the PDF files are not in the database machine.
    4. Metalink Note 1682771.1 (How to upload binary documents back to database blob column from forms). When I used this, I got ORA-6502 during the hextoraw conversion. In using this solution, I have downloaded a bin2hex.exe from the Google site. I've noticed that when I looked at the converted HEX file, each line has the character : (colon) at the beginning of each line. I know the PDF file has been converted correctly to HEX format because when I convert the HEX file back to BIN format using hex2bin.exe, I'm able to display the converted bin file in Acrobat Reader. When I removed the : (colon) in the HEX file, I did NOT get the ORA-6502 error but I CANNOT display the file in Acrobat Reader. It gives an error "corrupted file".
    5. upload facility in PL/SQL Web toolkit - I tried to automatically submit the html form (with htp.p) but it does NOT load the contents of the file. I called the URL from Oracle forms using web.show_document. There seems to be issues with Oracle Web forms (JInitiator) and HTML (+ htp.p).
    The other options I can think of at this point are:
    1. Use SQL*Loader to do the batch upload via SQL*Net connection and use HOST() built-in from Oracle Webforms to execute SQL*Loader from the 9iAS.
    2. Write a Visual Basic program that reads a binary file and output the contents of the file into a byte array. Then build a DLL that can be called from Oracle webforms 6i via ORA_FFI. I don't prefer this because it means the solution will only work for Windows.
    3. Write a JSP program that streams the PDF file and insert the contents of the PDF file into blob column via JDBC. Call JSP from forms using web.show_document. With this I have to do another connection to the database when I load the file.
    4. Maybe I can use dbms_lob by using network file system (NFS) between the application server and VMS. But this will be network resource hungry as far as I know because the network connection has to be kept open.
    Please advise. Thank you.
    Regards,
    Armando

    I have downloaded a bin2hex.exe from the Google site.
    ... each line has the character : (colon) at the
    beginning of each line. I'm afraid it isn't a correct utility. I hope you'll find the source code of a correct one at metalink forum:
    Doc ID: 368771.996
    Type: Forum
    Subject: Uploading Binary Files: bin2hex and hex2bin do not reproduce the same file
    There is some links to metalink notes and some example about working with BLOB at http://www.tigralen.spb.ru/oracle/blob/index.htm. Maybe it helps. Sorry for my English. If there is any problem with code provided there, let me know by e-mail.

  • How to upload a file into file system on server?

    We want to allow our partners to upload .csv file on our unix box. How do we upload a file into file system. I might be wrong but after reading the documentation, I think OA framework only allows to save the file in database. Please advise.
    Thanks,

    Hi,
    I was making a very silly mistake and found it. We need to create a new Entity object before you try to fill it with data. So what we can do is in the Controler, call a method in the AM that creates a new entity object (this should be made in processRequest, so that the VO gets initialized when the page loads).
    Now you can fill the entity with data in the page (ie browse and choose the file), and then when the page is submitted call a method AM again but now in processFormRequest to do the commit.
    code example
    In the AM class
    * Creates a new createCVRecord. To be Called from ProcessRequest when the page loads.
    public void createCVRecord()
    XxPersonCVVOImpl vo = getXxPersonCVVO1();
    if (!vo.isPreparedForExecution())
    vo.executeQuery();
    Row row = vo.createRow();
    vo.insertRow(row);
    // Required per OA Framework Model Coding Standard M69
    row.setNewRowState(Row.STATUS_INITIALIZED);
    } // end createCVRecord()
    * The commit method. To be Called from ProcessFormRequest when the page is submitted.
    public void apply()
    getTransaction().commit();
    or else there is a different way... please refer the following thread for more details....
    File Upload
    thanks to martin, who pointed out the mistake.

  • Uploading csv file into database using apex

    Dear all
    I am using apex 4 and oracle express 10g, i need to upload .csv file into the database for one of my appls, i have referred discussion forum for solutions, i found also, but some how its not working for me.
    below mentioned is error and the code
    ERROR:
    ORA-06550: line 38, column 8: PLS-00221: 'V_DATA_ARRAY' is not a procedure or is undefined ORA-06550: line 38, column 8: PL/SQL: Statement ignored ORA-06550: line 39, column 8: PLS-00221: 'V_DATA_ARRAY' is not a procedure or is undefined ORA-06550: line 39, column 8: PL/SQL: Statement ignored ORA-06550: line 40, column 8: PLS-00221: 'V_DATA_ARRAY' is not a procedure or is undefined ORA-06550: line 40, column 8: PL/SQL: Statement ignored ORA-06550: line 41, column 8: PLS-00221: 'V_DATA_ARRAY' is not a proc
    Error
    OK
    CODE:
    DECLARE
    v_blob_data BLOB;
    v_blob_len NUMBER;
    v_position NUMBER;
    v_raw_chunk RAW(10000);
    v_char CHAR(1);
    c_chunk_len number := 1;
    v_line VARCHAR2 (32767) := NULL;
    v_data_array wwv_flow_global.vc_arr2;
    BEGIN
    -- Read data from wwv_flow_files
    select blob_content into v_blob_data
    from wwv_flow_files where filename = 'DDNEW.csv';
    v_blob_len := dbms_lob.getlength(v_blob_data);
    v_position := 1;
    -- Read and convert binary to char
    WHILE ( v_position <= v_blob_len ) LOOP
    v_raw_chunk := dbms_lob.substr(v_blob_data,c_chunk_len,v_position);
    v_char := chr(hex_to_decimal(rawtohex(v_raw_chunk)));
    v_line := v_line || v_char;
    v_position := v_position + c_chunk_len;
    -- When a whole line is retrieved
    IF v_char = CHR(10) THEN
    -- Convert comma to : to use wwv_flow_utilities
    v_line := REPLACE (v_line, ',', ':');
    -- Convert each column separated by : into array of data
    v_data_array := wwv_flow_utilities.string_to_table (v_line);
    -- Insert data into target table
    EXECUTE IMMEDIATE 'insert into TABLE_X (v1, v2, v3, v4 ,v5, v6, v7,v8 ,v9, v10, v11)
    values (:1,:2,:3,:4,:5,:6,:7,:8,:9,:10,:11)'
    USING
    v_data_array(1),
    v_data_array(2),
    v_data_array(3),
    v_data_array(4);
    v_data_array(5);
    v_data_array(6);
    v_data_array(7);
    v_data_array(8);
    v_data_array(9);
    v_data_array(10);
    v_data_array(11);
    -- Clear out
    v_line := NULL;
    END IF;
    END LOOP;
    END;
    what i understand from this is system does not identify v_data_array as array for some reasons, please help me.
    initially system was giving error for hex_to_decimal, but i managed to get this function on discussion forum and now it seems to be ok. but v_data_array problem is still there.
    thanks in advance
    regards
    Uday

    Hi,
    Mistakes in your sample I did correct
    Problem 1
    select blob_content into v_blob_data
    from wwv_flow_files where filename = 'DDNEW.csv'; to
    select blob_content into v_blob_data
    from wwv_flow_files where name = :P1_FILE;Problem 2
    EXECUTE IMMEDIATE 'insert into TABLE_X (v1, v2, v3, v4 ,v5, v6, v7,v8 ,v9, v10, v11)
    values (:1,:2,:3,:4,:5,:6,:7,:8,:9,:10,:11)'
    USING
    v_data_array(1),
    v_data_array(2),
    v_data_array(3),
    v_data_array(4);
    v_data_array(5);
    v_data_array(6);
    v_data_array(7);
    v_data_array(8);
    v_data_array(9);
    v_data_array(10);
    v_data_array(11);  to
    EXECUTE IMMEDIATE 'insert into TABLE_X (v1, v2, v3, v4 ,v5, v6, v7,v8 ,v9, v10, v11)
    values (:1,:2,:3,:4,:5,:6,:7,:8,:9,:10,:11)'
    USING
    v_data_array(1),
    v_data_array(2),
    v_data_array(3),
    v_data_array(4),
    v_data_array(5),
    v_data_array(6),
    v_data_array(7),
    v_data_array(8),
    v_data_array(9),
    v_data_array(10),
    v_data_array(11);  And I did create missing table
    CREATE TABLE TABLE_X
        v1  VARCHAR2(255),
        v2  VARCHAR2(255),
        v3  VARCHAR2(255),
        v4  VARCHAR2(255),
        v5  VARCHAR2(255),
        v6  VARCHAR2(255),
        v7  VARCHAR2(255),
        v8  VARCHAR2(255),
        v9  VARCHAR2(255),
        v10 VARCHAR2(255),
        v11 VARCHAR2(255)
      );Regards,
    Jari
    Edited by: jarola on Nov 19, 2010 3:03 PM

  • Upload .txt file into Database Table

    Hi,
    I was wondering if someone could please point me in the right direction. I've been looking around the forum but can't find anything to help me achieve the following.
    I would like to be able to upload a .txt file using a webpage. Then store the information inside this file into database tables.
    eg. contents of mytextfile.txt:
    richard
    10 anywhere street, anytown, somewhere
    111 222 333 444
    joe
    9 somestreet, elsewhere
    999 888 777 666
    peter
    214 nearby lane, overhere
    555 555 555 555
    I would like to insert this data into a table.
    eg. table name = CONTACTS
    userid = primary key (using sequence)
    username = (line 1 - richard, joe, peter)
    address = (line 2)
    phone_no = (line 3)
    As you can see the records will appear 1 at a time and will have a blank line between records. Is there anyway for me to upload a file like this and have it placed into tables?
    I have seen http://otn.oracle.com/products/database/htmldb/howtos/howto_file_upload.html but this seems to be for uploading a whole file and downloading the same file, rather than extracting data from the file.
    I hope I have managed to explain my problem.
    Many thanks,
    Richard.

    Richard,
    HTML DB allows you to upload CSV files via the Data Workshop. That data would then be parsed and inserted into a specific table. Alternatively, if you have your data in an Excel spreadsheet, and it is less than 32k, you can copy & paste the data directly into HTML DB's Data Workshop, which will then parse and import it into the Oracle database.
    The one obstacle you may have to overcome is converting your data from the format you outlined to CSV format. Specifically, you would have to make this:
    richard
    10 anywhere street, anytown, somewhere
    111 222 333 444
    Look something like this:
    "richard","10 anywhere street, anytown, somewhere","111 222 333 444"
    Hope this helps,
    - Scott -

  • How to upload a file into specified location

    Hi Frndz..
    How to upload a file using File upload feature in web dynpro into our specified location(usr/sap/Images/....),not into  workspace r default path in server.
    Thanks in Advance
    Regards
    Rajesh

    Hi Rajesh,
    Use below code on your "Upload" Action:
         try
    // Give full path of folder on server where you want to upload the file.
              File file = new File("D:\\usr\\sap\\Images\\"+wdContext.currentContextElement().getResource().getResourceName().toString());
    // D:\usr\sap\Images folder should present on server
              FileOutputStream op = new FileOutputStream(file);
              if(wdContext.currentContextElement().getResource()!=null)
                   text=wdContext.currentContextElement().getResource().read(false);
                        while((temp=text.read())!=-1)
                             op.write(temp);
              op.flush();
              op.close();
         catch(Exception e)
              wdComponentAPI.getMessageManager().reportSuccess("Error while uploading file : "+e.getMessage());
    Thanks
    Sandy

  • How to convert .doc file into .rtf file in Java?

    Hello All,
    I want to convert doc file into rtf format in java and for the same i am not getting any help so pls suggest some solution for that.
    Thanks and Regards
    only1Vinay

    MS-Word formats (DOC) are notorious for not being standardized from one version to another, so what ever you get will be version specific. If you must do the conversion, I suggest you do a MS-Script in Word to do it or one of the .Net languages. As stated the Word format from version to version is not standardized.

Maybe you are looking for

  • List of Open Sales Orders

    Hi All,         I  am in need of a report to display  list of open Sales orders, Requirement Date or Requested Delivery Date and Requirement Qty for given Materials (Multiple Input) and Plant. Please guide me, Is there any Standard Report Available t

  • Showing as 2 Separate Albums

    I have a 2CD set that I've imported into itunes that is showing up as 2 separate albums (1 for each cd). Obviously I want this to show up (in grid and coverflow view) as a single album. *So - I've done the following:* In list view I highlighted all o

  • Delete button not working on the desktop

    Hello There, I am a new mac user. I don't know but for some reason, delete button on the desktop is not working, i.e. if I want to delete something I have to right click and then select "move to trash", is there are workaround for that, or it is like

  • Weblogic saml2 Custom Principal cannot be added to the subject

    Dear All I have written a custom Identity Asserter Attribute Name Mapper in the SP side.In that I was trying to add the custom attributes to the subject Via Custom principals. The Subject came there as read only .hence i could not be able to add the

  • MX 7.01 Server Lockup due to down database

    We have two datasources A) Standard SQL database, in the same domain B) SQL database pulled accross a VPN. Then we have a two load balanced CF servers. We host multiple websites, one website (We'll call it Bob) connects to both database A and B The r