Uploading selected files

I have an insert record form i created. It uploads all the info I need to a MYSQL database like I want it to. The only thing I need is to upload the three files I selected on the form to also copy to a folder on the server. Thanks.

[php]

<?php require_once('Connections/uploads2.php'); ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $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;
}
}

$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 listings (property_ID, address1, address2, county, price, description, filename1, filesize1, filetype1, caption1, filename2, filetype2, filesize2, caption2, filename3, filetype3, filesize3, caption3) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)”,
GetSQLValueString($_POST[‘property_ID’], “text”),
GetSQLValueString($_POST[‘address1’], “text”),
GetSQLValueString($_POST[‘address2’], “text”),
GetSQLValueString($_POST[‘county’], “text”),
GetSQLValueString($_POST[‘price’], “text”),
GetSQLValueString($_POST[‘description’], “text”),
GetSQLValueString($_POST[‘filename1’], “text”),
GetSQLValueString($_POST[‘filesize1’], “text”),
GetSQLValueString($_POST[‘filetype1’], “text”),
GetSQLValueString($_POST[‘caption1’], “text”),
GetSQLValueString($_POST[‘filename2’], “text”),
GetSQLValueString($_POST[‘filetype2’], “text”),
GetSQLValueString($_POST[‘filesize2’], “text”),
GetSQLValueString($_POST[‘caption2’], “text”),
GetSQLValueString($_POST[‘filename3’], “text”),
GetSQLValueString($_POST[‘filetype3’], “text”),
GetSQLValueString($_POST[‘filesize3’], “text”),
GetSQLValueString($_POST[‘caption3’], “text”));

mysql_select_db($database_uploads2, $uploads2);
$Result1 = mysql_query($insertSQL, $uploads2) or die(mysql_error());
}

mysql_select_db($database_uploads2, $uploads2);
$query_Recordset1 = “SELECT listings.property_ID, listings.address1, listings.address2, listings.county, listings.price, listings.description, listings.filename1, listings.filesize1, listings.filetype1, listings.caption1, listings.filename2, listings.filetype2, listings.filesize2, listings.caption2, listings.filename3, listings.filetype3, listings.filesize3, listings.caption3 FROM listings ORDER BY listings.property_ID”;
$Recordset1 = mysql_query($query_Recordset1, $uploads2) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);

mysql_free_result($Recordset1);
?>
<!doctype html>

Add Home Listing

Property ID No.:

Address Line 1:

City, State, Zipcode:

County:

Price:

File1:

File1 Caption:

File2:

File2 Caption:

File3:

File3 Caption:

Description:

[/php]

Well, uploading files is easy. Here is a simple tutorial that explains it. If you have trouble post
your upload code and we can help… On this site, they show examples of other types of things you
may be interested in. Hope it helps…

http://www.w3schools.com/php/php_file_upload.asp

Sponsor our Newsletter | Privacy Policy | Terms of Service