bigshwa05 Posted June 5, 2006 Share Posted June 5, 2006 I am trying to create a form to uplaod an image along with some form data. I can get the form to write the text values into the database however the image does not seem to upload. I m not sure what to try next!<? //connect mysql_connect("myHost","userName","password"); //select which database you want to edit mysql_select_db("dataBase"); ?><? //initilize PHPif($_POST['submit']) //If submit is hit{ //convert all the posts to variables: $bizname = $_POST['bizname']; $bizwebsite = $_POST['bizwebsite']; $bizcategory = $_POST['bizcategory']; $bizdescription = $_POST['bizdescription']; $imagename = $_FILES['image']['name']; copy ($_FILES['image']['tmp_name'], "../images/".$_FILES['image']['name']) or die ('Could not upload'); $result=MYSQL_QUERY("INSERT INTO bizdir ( id, bizname, bizwebsite, bizcategory, bizdescription imagename)". "VALUES ('NULL', '$bizname', '$bizwebsite', '$bizcategory', '$bizdescription','$imagename')"); echo '<p>test</p>'; }else{// close php so we can put in our code?><form method="post" action="addbiz.php"><TABLE><TR> <TD>Business Name:</TD> <TD><INPUT TYPE='TEXT' NAME='bizname' VALUE='Random Name' size=60></TD></TR><TR> <TD>Website:</TD> <TD><INPUT TYPE='TEXT' NAME='bizwebsite' VALUE='' size=60></TD></TR><br><TR> <TD>CATEGORY:</TD> <TD><INPUT TYPE='TEXT' NAME='bizcategory' VALUE='' size=60></TD></TR><TR> <TD>Description:</TD> <TD> <!-- You can use PHP functions to automatically get the value of time --> <TEXTAREA NAME='bizdescription' VALUE='description' rows="10" cols="30"></TEXTAREA> </TD></TR><TR> <TD>Image:</TD> <TD> <!-- You can use PHP functions to automatically get the value of time --> <input type="file" name="image"> </TD></TR><TR> <TD></TD><br> <TD><INPUT TYPE="submit" name="submit" value="submit"></TD> </TR></TABLE></form><?} //close the else statement?> Link to comment https://forums.phpfreaks.com/topic/11209-upload-image-and-add-path-to-mysql-database/ Share on other sites More sharing options...
litebearer Posted June 6, 2006 Share Posted June 6, 2006 As a start try changing this[code]<form method="post" action="addbiz.php">[/code]to this[code]<form enctype="multipart/form-data" action="addbiz.php" method="post">[/code]Lite... Link to comment https://forums.phpfreaks.com/topic/11209-upload-image-and-add-path-to-mysql-database/#findComment-42289 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.