Hello
I'm using mysql databases and php via dreamweaver for the scripting.
I have worked out how to submit images to a database and retrieve them.
How to just use the image_location to insert dynamic images into a webpage etc.
But I'm really struggling in working out how to just upload regular file types such as .pdf or .doc files to a database in a manner in which they can then be retrieved by customers looking at the website.
Ideally I just want to insert one more line to this form for .pdf file uploads:
<?php require_once('Connections/erinpubl_localhost.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 eph_product (prod_id, prod_name, prod_level, prod_price, prod_status, image, thumbnail, prod_exercise) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['prod_id'], "text"),
GetSQLValueString($_POST['prod_name'], "text"),
GetSQLValueString($_POST['prod_level'], "text"),
GetSQLValueString($_POST['prod_price'], "text"),
GetSQLValueString($_POST['prod_status'], "text"),
GetSQLValueString($_POST['image'], "text"),
GetSQLValueString($_POST['thumbnail'], "text"),
GetSQLValueString($_POST['prod_exercise'], "text"));
mysql_select_db($database_erinpubl_localhost, $erinpubl_localhost);
$Result1 = mysql_query($insertSQL, $erinpubl_localhost) or die(mysql_error());
}
?>
<!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>Inserting Product Records</title>
</head>
<body>
<p>Insert a New Product Record</p>
<table width="529" border="1">
<tr>
<td>Please enter details of the new product, including full location URL of images.</td>
</tr>
<tr>
<td height="230"><form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1">
<table align="left">
<tr valign="baseline">
<td nowrap="nowrap" align="right">Product ID:</td>
<td><input type="text" name="prod_id" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Prod_name:</td>
<td><input type="text" name="prod_name" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Prod_level:</td>
<td><input type="text" name="prod_level" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Prod_price:</td>
<td><input type="text" name="prod_price" value="" size="32" /></td>
</tr>
<td nowrap="nowrap" align="right">prod_status:</td>
<td><input type="text" name="prod_status" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">image:</td>
<td><input name="image" type="text" value="" size="50" maxlength="80" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">thumbnail:</td>
<td><input name="thumbnail" type="text" value="" size="50" maxlength="80" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">prod_exercise:</td>
<td><input name="prod_exercise" type="text" value="" size="50" maxlength="80" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"> </td>
<td><input type="submit" value="Insert record" /></td>
</tr>
</table>
<p>
<input type="hidden" name="MM_insert" value="form1" />
</p>
<p> </p>
<p> </p>
</form>
<p> </p></td>
</tr>
</table>
</body>
</html>