Java mysql play framework about uploading file data to db

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • EVAS
    New Member
    • Nov 2007
    • 8

    Java mysql play framework about uploading file data to db

    i think this is mysql question.correc t me if its java!
    I am using play framework (mvc java for web app).
    my question is that i want to save data from (.txt) file to mysql. So i got upload.html :
    Code:
    <form action="mplapla" method="POST" enctype="multipart/form-data">
       <input type="file" name="filename" />
            <input type="submit" value="upload file"/>
    </form>
    and for the action i got
    ......
    QUERY= "LOAD DATA INFILE '"+filename+ "' INTO TABLE mytAble;";
    ......
    which doesnt work.if i do
    query = "LOAD DATA INFILE 'c://myfile.txt' INTO TABLE mytAble;";
    works fine(puts the data of myfile to mysql table)
    what can i do ? any help appricieted !!
  • johny10151981
    Top Contributor
    • Jan 2010
    • 1059

    #2
    I hope there is a function available in your java api library

    mysql_real_esca pe_string, use this function to filter your filename. and then do this
    Code:
    QUERY= "LOAD DATA INFILE '"+filename+"' INTO TABLE mytAble;";

    Comment

    Working...