upload a word doc file to a folder on the server. At the same time I need to
add the name of the file (e.g. myfile.doc) to a field in a table in the database.
I'm working with the following code at the moment:
Code: Select all
if ((isset($_POST["upload"])) && ($_POST["upload"] == "form1")) {
$insertSQL = sprintf("INSERT INTO word (wordName, wordDetails) VALUES (%s,
%s)",
GetSQLValueString($_POST['userfile'], "text"),
GetSQLValueString($_POST['wordDetails'], "text"));
******************
<input type="file" id="userfile" name="userfile">
Programme Note Details:<input type="text" name="wordDetails" value=""
size="32">I have no problem in sending the file to the folder (permissions etc) but
when I want to add the text name of the file to my MySql database this is
where I run into trouble. Basically if I use <input type="file"
id="userfile" name="userfile"> this will try (I think) and send the whole
string C:\myfile.doc to the database when I only want myfile.doc to be
submitted. Also I think that as this is a file that is been actually sent to
a folder in the root that there is probably a conflict when trying to send
the name and extension to the database.
Any pointers as to how to deal with this and if the code above will work
somehow?
Thanks a mil
Brian