By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,952 Members | 916 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,952 IT Pros & Developers. It's quick & easy.

Java mysql play framework about uploading file data to db

P: 8
i think this is mysql question.correct 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 :
Expand|Select|Wrap|Line Numbers
  1. <form action="mplapla" method="POST" enctype="multipart/form-data">
  2.    <input type="file" name="filename" />
  3.         <input type="submit" value="upload file"/>
  4. </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 !!
Mar 23 '12 #1
Share this Question
Share on Google+
1 Reply

P: 1,059
I hope there is a function available in your java api library

mysql_real_escape_string, use this function to filter your filename. and then do this
Expand|Select|Wrap|Line Numbers
  1. QUERY= "LOAD DATA INFILE '"+filename+"' INTO TABLE mytAble;";
Mar 30 '12 #2

Post your reply

Sign in to post your reply or Sign up for a free account.