In this example I am uploading to the file system, but saving the location in mySQL to reference later.
<form action="insert.php" enctype="multipart/form-data" method="post">
<input name="MAX_FILE_SIZE" type="hidden" value="20000000" />
<input name="fileupload" type="file" />
<input alt="Submit Form"/>
</form>
--------------------------------------------------------------
//Database variables are located with-in here
include("dataconnection.php");
$con = mysql_connect($hostname, $username, $password);
if (!$con)
{ die('Could not connect: '); }
$selected = mysql_select_db($dbname);
//Generate Random Number & date to add to file name so they're always unique
$rNumb=rand();
$today = getdate();
$id=$today['mon'].$today['mday'].$today['year']." ".$rNumb;
$id2=str_replace(" ","",$id);
//Move temp file auto created to permanent location
$uploadfile = 'uploadfiles/' . $id2 . basename($_FILES['fileupload']['name']);
if (move_uploaded_file($_FILES['fileupload']['tmp_name'], $uploadfile)) { }
else {}
//Check to see if anything was uploaded, otherwise set variable to nothing
if($uploadfile == 'uploadfiles/' . $id2)
{$uploadfile = "";}
if (!mysql_query($sql,$con))
{ die('There was an issue, please go back and try again, if it still happens please contact technical support'); }
mysql_close($con)
?>