I have a form that uploads 3 files (thumb, 4x6, 6x9) at one time into a directory called "images/". This works wonderful. But I need to also insert the names (and other information) into the database. I can't figure out the logic on how to perform this part.
Any help is appreciated
TIA
Here is my current code:
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO photo_table (photo_id, photo_client_id, photo_category, photo_name, photo_keyword, photo_desc, photo_thumb_name, photo_4x6_name, photo_6x9_name) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['photo_id'], "int"),
GetSQLValueString($_POST['photo_client_id'], "int"),
GetSQLValueString($_POST['photo_category'], "int"),
GetSQLValueString($_POST['photo_name'], "text"),
GetSQLValueString($_POST['photo_keyword'], "text"),
GetSQLValueString($_POST['photo_desc'], "text"),
GetSQLValueString($_POST['upfile[]'], "text"),
GetSQLValueString($_POST['upfile[]'], "text"),
GetSQLValueString($_POST['upfile[]'], "text"));
mysql_select_db($database_database, $database);
$Result1 = mysql_query($insertSQL, $database) or die(mysql_error());
$numoffile = 3;
// Fix path of your file to be uploaded, don't forget to CHMOD 777 to this folder
$file_dir = "images/";
if ($_POST) {
for ($i=0;$i<$numoffile;$i++) {
if (trim($_FILES['upfile']['name'][$i])!="") {
$newfile = $file_dir.$_FILES['upfile']['name'][$i];
move_uploaded_file($_FILES['upfile']['tmp_name'][$i], $newfile);
$j++;
}
}
}
Input fields of form
<td><input name="upfile[]1" type="file" tabindex="2" size="35" /></td>
</tr>
<tr>
<td height="55"> td>
<td>Photo_desc:</td>
<td><input type="text" name="photo_desc" value="" size="32" /></td>
<td>Select 4 x 6 Photo</td>
<td><input name="upfile[]2" type="file" tabindex="3" size="35" /></td>
</tr>
<tr>
<td height="48"> </td>
<td> </td>
<td> </td>
<td>Select 6 x 9 Photo</td>
<td><input name="upfile[]3" type="file" size="35" /></td>
Any help is appreciated
TIA
Here is my current code:
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO photo_table (photo_id, photo_client_id, photo_category, photo_name, photo_keyword, photo_desc, photo_thumb_name, photo_4x6_name, photo_6x9_name) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['photo_id'], "int"),
GetSQLValueString($_POST['photo_client_id'], "int"),
GetSQLValueString($_POST['photo_category'], "int"),
GetSQLValueString($_POST['photo_name'], "text"),
GetSQLValueString($_POST['photo_keyword'], "text"),
GetSQLValueString($_POST['photo_desc'], "text"),
GetSQLValueString($_POST['upfile[]'], "text"),
GetSQLValueString($_POST['upfile[]'], "text"),
GetSQLValueString($_POST['upfile[]'], "text"));
mysql_select_db($database_database, $database);
$Result1 = mysql_query($insertSQL, $database) or die(mysql_error());
$numoffile = 3;
// Fix path of your file to be uploaded, don't forget to CHMOD 777 to this folder
$file_dir = "images/";
if ($_POST) {
for ($i=0;$i<$numoffile;$i++) {
if (trim($_FILES['upfile']['name'][$i])!="") {
$newfile = $file_dir.$_FILES['upfile']['name'][$i];
move_uploaded_file($_FILES['upfile']['tmp_name'][$i], $newfile);
$j++;
}
}
}
Input fields of form
<td><input name="upfile[]1" type="file" tabindex="2" size="35" /></td>
</tr>
<tr>
<td height="55"> td>
<td>Photo_desc:</td>
<td><input type="text" name="photo_desc" value="" size="32" /></td>
<td>Select 4 x 6 Photo</td>
<td><input name="upfile[]2" type="file" tabindex="3" size="35" /></td>
</tr>
<tr>
<td height="48"> </td>
<td> </td>
<td> </td>
<td>Select 6 x 9 Photo</td>
<td><input name="upfile[]3" type="file" size="35" /></td>