BarneyJoe Posted November 25, 2006 Share Posted November 25, 2006 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 :[CODE]<form action="<?php echo $editFormAction; ?>" method="POST" enctype="multipart/form-data" name="form1" id="form1">[/CODE]where edit form action is pointing to a confirmation page.My input file field :[CODE]<input name="Image" type="file" size="55"> <input type="hidden" name="MAX_FILE_SIZE" value="25000" />[/CODE]The code in the confirmation page to move the file to the relevant folder :[CODE]<?phpmove_uploaded_file ($_FILES['Image'] ['tmp_name'], "/pathtofolder/{$_FILES['Image'] ['name']}")?>[/CODE]But the place I think I'm going wrong is the insert record code :[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"));[/CODE]The record is being added, but the file isn't uploading...Anyone spot where I've gone wrong?Cheers,Iain Link to comment https://forums.phpfreaks.com/topic/28421-uploading-images-and-putting-file-name-in-a-text-field/ Share on other sites More sharing options...
printf Posted November 25, 2006 Share Posted November 25, 2006 missing semicolon [b];[/b], at the end of the [b]move_uploaded_file ()[/b] function!printf Link to comment https://forums.phpfreaks.com/topic/28421-uploading-images-and-putting-file-name-in-a-text-field/#findComment-130070 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.