I think I'm along the right track with this, but seem to be going wrong somewhere.
What I'm trying to do is have a form to upload info into a table. Each record also has an attached image, the file name needing to be in a file name field to point to the image.
So I have my form :
<form action="<?php echo $editFormAction; ?>" method="POST" enctype="multipart/form-data" name="form1" id="form1">
where edit form action is pointing to a confirmation page.
My input file field :
<input name="Image" type="file" size="55">
<input type="hidden" name="MAX_FILE_SIZE" value="25000" />
The code in the confirmation page to move the file to the relevant folder :
<?php
move_uploaded_file ($_FILES['Image'] ['tmp_name'],
"/pathtofolder/{$_FILES['Image'] ['name']}")
?>
But the place I think I'm going wrong is the insert record code :
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO Carpets (CarpetRef, Carpet, Price, Image, Description, `Size`) VALUES (%s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['CarpetRef'], "text"),
GetSQLValueString($_POST['Carpet'], "text"),
GetSQLValueString($_POST['Price'], "double"),
GetSQLValueString($_FILES['Image']['name'], "text"),
GetSQLValueString($_POST['description'], "text"),
GetSQLValueString($_POST['Size'], "text"));
The record is being added, but the file isn't uploading...
Anyone spot where I've gone wrong?
Cheers,
Iain