Hi there, am new to php and i have been trying to upload files from a form to a location on a server ( folder "uploads" on the server), the syntax and everything i am using is right cos i tried using just a form but when ever i use it here it just doesn't upload. Can some one please help me out. The whole code for the page is below. thank you
<?php require_once('Connections/project_database.php'); ?>
<?php
/*Session starts so as to access unique email from personal details form*/
session_start();
$email = $_SESSION['form1']['email'];
/*To upload pictures and video to server*/
if($_POST[upload]=="1")
{
$to ="uploads/".$_FILES['picture']['name'];
move_uploaded_file($_FILES['picture']['tmp_name'], $to);
$to ="uploads/".$_FILES['picture2']['name'];
move_uploaded_file($_FILES['picture2']['tmp_name'], $to);
$to ="uploads/".$_FILES['picture3']['name'];
move_uploaded_file($_FILES['picture3']['tmp_name'], $to);
$to ="uploads/".$_FILES['video']['name'];
move_uploaded_file($_FILES['video']['tmp_name'], $to);
}
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
mysql_select_db($database_project_database, $project_database);
$query_rsEmail = "SELECT personal.email FROM personal WHERE personal.email='$email'";
$rsEmail = mysql_query($query_rsEmail, $project_database) or die(mysql_error());
$row_rsEmail = mysql_fetch_assoc($rsEmail);
$totalRows_rsEmail = mysql_num_rows($rsEmail);
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO property (email, certNo, proptype, propintent, rooms, plotsize, price, `add`, `state`, lga, picture, picture2, picture3, video) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['email'], "text"),
GetSQLValueString($_POST['certNo'], "text"),
GetSQLValueString($_POST['proptype'], "text"),
GetSQLValueString($_POST['propintent'], "text"),
GetSQLValueString($_POST['rooms'], "int"),
GetSQLValueString($_POST['plotsize'], "int"),
GetSQLValueString($_POST['price'], "int"),
GetSQLValueString($_POST['add'], "text"),
GetSQLValueString($_POST['state'], "text"),
GetSQLValueString($_POST['lga'], "text"),
GetSQLValueString($_POST['picture'], "text"),
GetSQLValueString($_POST['picture2'], "text"),
GetSQLValueString($_POST['picture3'], "text"),
GetSQLValueString($_POST['video'], "text"));
mysql_select_db($database_project_database, $project_database);
$Result1 = mysql_query($insertSQL, $project_database) or die(mysql_error());
$insertGoTo = "confirm.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>:: Property Registration ::</title>
<link rel="stylesheet" type="text/css" href="style.css"/>
<script src="SpryValidationTextField.js" type="text/javascript"></script>
<link href="SpryValidationTextField.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="container">
<div id="header"><br />
<br />
<br />
</div>
<div id="menu">
</div>
<div id="othersmain">
<h1>Registration</h1>
<p>Continue registration some other time? <a href="index.html">yes</a></p>
<form action="<?php echo $editFormAction; ?>" method="POST" name="form1" id="form1" encytype="multipart/form-data">
<input type="hidden" name="upload" value="1" />
<table width="526" border="0" align="center">
<caption>
Property Details
</caption>
<input name="email" type="hidden" value="<?php echo $row_rsEmail['email']; ?>"/>
<tr>
<td width="251">Cert. of Occupancy No. :</td>
<td width="259"><span id="sprytextfield1">
<label>
<input name="certNo" type="text" id="certNo" size="30" />
</label>
<span class="textfieldRequiredMsg">A value is required.</span></span></td>
</tr>
<tr>
<td>Type of property :</td>
<td><select name="proptype" id="proptype">
<option>- Property Type -</option>
<option>bungalow</option>
<option>flat</option>
<option>storey</option>
<option>plot</option>
<option>shop</option>
</select></td>
</tr>
<tr>
<td>Intent for advertisement :</td>
<td align="left"><select name="propintent" id="propintent">
<option selected="selected">- Select Category-</option>
<option>sell</option>
<option>lease</option>
</select></td>
</tr>
<tr>
<td>Number of Rooms :</td>
<td>
<label>
<input name="rooms" type="text" id="rooms" size="30" />
</label>
</td>
</tr>
<tr>
<td>Plot Size :</td>
<td><span id="sprytextfield3">
<input name="plotsize" type="text" id="plotsize" size="30" />
<span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span>SQM</td>
</tr>
<tr>
<td>Price (=N=) :</td>
<td align="left"><span id="sprytextfield4">
<label>
<input name="price" type="text" id="price" size="30" />
</label>
<span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">1,000,000.00.</span></span></td>
</tr>
<tr>
<td>Address :</td>
<td><span id="sprytextfield5">
<label>
<input name="add" type="text" id="add" size="30" />
</label>
<span class="textfieldRequiredMsg">A value is required.</span></span></td>
</tr>
<tr>
<td>State :</td>
<td><label>
<select name="state" id="state">
<option selected="selected">- State -</option>
<option>Abia</option>
<option>Adamawa</option>
<option>Akwa Ibom</option>
<option>Anambra</option>
<option>Bauchi</option>
<option>Bayelsa</option>
<option>Benue</option>
<option>Borno</option>
<option>Cross River</option>
<option>Delta</option>
<option>Ebonyi</option>
<option>Edo</option>
<option>Ekiti</option>
<option>Enugu</option>
<option>Gombe</option>
<option>Imo</option>
<option>Jigawa</option>
<option>Kaduna</option>
<option>Kano</option>
<option>Katsina</option>
<option>Kebbi</option>
<option>Kogi</option>
<option>Kwara</option>
<option>Lagos</option>
<option>Nasarawa</option>
<option>Niger</option>
<option>Ogun</option>
<option>Ondo</option>
<option>Osun</option>
<option>Oyo</option>
<option>Plateau</option>
<option>Rivers</option>
<option>Sokoto</option>
<option>Taraba</option>
<option>Yobe</option>
<option>Zamfara</option>
<option>F.C.T</option>
</select>
</label></td>
</tr>
<tr>
<td>Local Govt. Area :</td>
<td><span id="sprytextfield6">
<label>
<input name="lga" type="text" id="lga" size="30" />
</label>
<span class="textfieldRequiredMsg">Ps Enter Local Govt. Area.</span></span></td>
</tr>
<tr>
<td>Picture :</td>
<td><label>
<input name="picture" type="file" id="picture" size="30" />
</label></td>
</tr>
<tr>
<td>Picture :</td>
<td><input name="picture2" type="file" id="picture2" size="30" /></td>
</tr>
<tr>
<td>Picture :</td>
<td><input name="picture3" type="file" id="picture3" size="30" /></td>
</tr>
<tr>
<td>Video :</td>
<td><label>
<input name="video" type="file" id="video" size="30" />
</label></td>
</tr>
<tr>
<td colspan="2"><div align="center">
<label>
<input type="submit" name="property" id="property" value="Make Entry" />
</label>
</div></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1" />
</form>
<!-- end #mainContent --></div>
<div id="footer">
<p>©2008 <span class="separator">|</span>
Ibrahim Suleiman Sani (0613075)</p>
<!-- end #footer --></div>
<!-- end #container --></div>
<script type="text/javascript">
<!--
var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1", "none", {validateOn:["change"]});
var = new Spry.Widget.ValidationTextField("", "integer", {validateOn:["change"]});
var sprytextfield3 = new Spry.Widget.ValidationTextField("sprytextfield3", "integer", {validateOn:["change"]});
var sprytextfield4 = new Spry.Widget.ValidationTextField("sprytextfield4", "currency", {validateOn:["change"]});
var sprytextfield5 = new Spry.Widget.ValidationTextField("sprytextfield5", "none", {validateOn:["change"]});
var sprytextfield6 = new Spry.Widget.ValidationTextField("sprytextfield6", "none", {validateOn:["change"]});
//-->
</script>
</body>
</html>
<?php
mysql_free_result($rsEmail);
?>