cant seem to get anything to store in the database field for image_data (which is the LOAD_FILE('$tempName') in the insert command
it is a blob type database field, and keeps storing as 0 bytes on save
subs.php contains my database login info
the javascript is just to preview the image before uploading
<?
include("Subs.php");
global $settings;
if(isset($_GET['action'])){$action = $_GET['action'];
if($_GET['action'] == "add"){doAdd();}}
else {
doheader('Add a person);
echo '
<head>
<SCRIPT type="text/javascript">
<!--
/***** CUSTOMISE THESE VARIABLES *****/
var maxWidth=200;
// width to resize large images to
var maxHeight=100;
// height to resize large images to
var fileTypes=["bmp","gif","png","jpg","jpeg"];
// valid file types
var outImage="previewField";
// the id of the preview image tag
var defaultPic="images/b.gif";
// what to display when the image is not valid
/***** DO NOT EDIT BELOW *****/
function preview(what){
var source=what.value;
var ext=source.substring(source.lastIndexOf(".")+1,source.length).toLowerCase();
for (var i=0; i<fileTypes.length; i++) if (fileTypes[i]==ext) break;
globalPic=new Image();
if (i<fileTypes.length) globalPic.src=source;
else {
globalPic.src=defaultPic;
alert("THAT IS NOT A VALID IMAGE\nPlease load an image with an extention of one of the following:\n\n"+fileTypes.join(", "));
}
setTimeout("applyChanges()",200);
}
var globalPic;
function applyChanges(){
var field=document.getElementById(outImage);
var x=parseInt(globalPic.width);
var y=parseInt(globalPic.height);
if (x>maxWidth) {
y*=maxWidth/x;
x=maxWidth;
}
if (y>maxHeight) {
x*=maxHeight/y;
y=maxHeight;
}
field.style.display=(x<1 || y<1)?"none":"";
field.src=globalPic.src;
field.width=x;
field.height=y;
}
//-->
</SCRIPT>
</head>
<center>
<h5>Add person</h5>
<span style="width: 500px; text-align: left;">
<form name="main" action="people_add.php?action=add" method="post" enctype="multipart/form-data">
<span style="width: 200px; text-align: left;">name:</span> <input type="text" name="name" maxlength="25" tabindex="1" size="20" /> <br />
<span style="width: 200px; text-align: left;">dob:</span> <input type="text" name="dob" maxlength="10" tabindex="2" size="20" /><br />
<span style="width: 200px; text-align: left;">hair:</span> <input type="text" name="hair" maxlength="50" tabindex="3" size="20" /> <br />
<span style="width: 200px; text-align: left;">eyes:</span> <input type="text" name="eyes" maxlength="10" tabindex="4" size="20" /> <br />
<span style="width: 200px; text-align: left;">gender:</span> <input type="text" name="gender" maxlength="10" tabindex="5" size="20" /> <br />
<span style="width: 200px; text-align: left;">edu:</span> <input type="text" name="edu" maxlength="10" tabindex="6" size="18" /> <br />
<span style="width: 200px; text-align: left;">Show this item?</span> <input class="noborder" type="checkbox" name="shown" tabindex="7" value="1" checked /><font size="2"> [Checked for yes] </font><br />
<span style="width: 200px; text-align: left;">Photo:</span> <input name="filename" type="file" onchange="preview(this)" tabindex="8" /> <br />
<span style="width: 500px; text-align: center;"><IMG alt="preview" id="previewField" src="'.$settings['url'].'/images/b.gif" /> </span> <br />
Details:<br /><textarea tabindex="9" name="details" style="width: 500px; height: 6em;"></textarea> <br />
<center><input tabindex="10" type="submit" class="submit" value="Submit" /> <input tabindex="11" type="reset" class="submit" value="Reset" /></center>
</form>
</span>
</center>
';
}
function doAdd(){
doheader('person Added');
$_POST['name'] = ucwords(strtolower(addslashes($_POST['name'])));
$_POST['dob'] = $_POST['dob'];
$_POST['hair'] = ucwords(strtolower(addslashes($_POST['hair'])));
$_POST['eyes'] = $_POST['eyes'];
$_POST['gender'] = $_POST['gender'];
$_POST['edu'] = $_POST['edu'];
$_POST['details'] = addslashes(nl2br($_POST['details']));
$fileName = $_FILES['filename']['name'];
$tempName = $_FILES['filename']['tmp_name'];
$fileType = $_FILES['filename']['type'];
$fileSize = getimagesize($_FILES['filename']['tmp_name']);
if (is_uploaded_file($tempName)) {
$tempName = mysql_escape_string($tempName);
$query = mysql_query
("INSERT INTO computers VALUES('','$_POST[name]','$_POST[dob]','$_POST[hair]','$_POST[eyes]','$_POST[gender]','$_POST[edu]','$_POST[shown]','$fileName','$fileType','{$fileSize['3']}',LOAD_FILE('$tempName'),'$_POST[details]')") or die(mysql_error());
} else {
$query = mysql_query
("INSERT INTO computers VALUES('','$_POST[name]','$_POST[dob]','$_POST[hair]','$_POST[eyes]','$_POST[gender]','$_POST[edu]','$_POST[shown]', '', '', '', '','$_POST[details]')") or die(mysql_error());
}
header("Location: people.php");
exit;
}
dofooter();
?>