The following code is from an edit.php script. It updates all but the file uploads. I’ve not been able to spot what is preventing their update, should the filePaths be stored in some variable, like the other fields? Would someone assist?
<!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" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
<style type="text/css" media="all">
@import "c/cms_styles.css";
</style>
</head>
<body>
<div id="container">
<?php
require_once('######.php');
$uploadDir = './upload/';
if(isset($_GET['talent_id']))
{
$q = "SELECT * ".
"FROM ###### ".
"WHERE talent_id = '{$_GET['talent_id']}'";
$r = mysqli_query($dbc,$q) or die('Error : ' . mysqli_error($dbc));
list($talent_id, $first_name,$last_name, $speciality, $website, $resumePath, $headshotPath, $registration_date) = mysqli_fetch_array($r, MYSQL_NUM);
}
else if(isset($_POST['update']))
{
$talent_id = $_POST['talent_id'];
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$speciality = $_POST['speciality'];
$website = $_POST['website'];
$resumePath = $_POST['resumePath'];
$headshotPath = $_POST['headshotPath'];
if ($_FILES['resume']['size'] > 0 ) {
$resumeName = $_FILES['resume']['name'];
$resumeTmpName = $_FILES['resume']['tmp_name'];
$resumeFileSize = $_FILES['resume']['size'];
$resumeFileType = $_FILES['resume']['type'];
$resumePath = $uploadDir . $resumeName;
$resumeResult = move_uploaded_file($resumeTmpName, $resumePath);
if (!$resumeResult) {
echo "Error uploading resume file";
exit;
}else{
echo "<p>Resume Upload Complete.</p>";
}
}
if ($_FILES['headshot']['size'] > 0 ) {
$headshotName = $_FILES['headshot']['name'];
$headshotTmpName = $_FILES['headshot']['tmp_name'];
$headshotFileSize = $_FILES['headshot']['size'];
$headshotFileType = $_FILES['headshot']['type'];
$headshotPath = $uploadDir . $headshotName;
/* $docCatagory = 'resume';
echo "<p>$docCatagory</p>";
$resumePath = $uploadDir . $resumeName;
echo "<p>$resumePath</p>";
*/
$headshotResult = move_uploaded_file($headshotTmpName, $headshotPath);
if (!$headshotResult) {
echo "Error uploading headshot file";
exit;
}else{
echo "<p>Headshot Upload Complete.</p>";
}
}
// update the article in the database
$q = "UPDATE production ".
"SET first_name = '$first_name',last_name='$last_name', speciality= '$speciality', website= '$website' , resumePath = '$resumePath' , headshotPath = '$headshotPath' ".
"WHERE talent_id = '$talent_id'";
mysqli_query($dbc,$q) or die('Error : ' . mysqli_error($dbc));
echo "<p>Talent Updated</p>";
}
mysqli_close($dbc);
?>
<h3> Update Production Talent:</h3>
<form action="prod_edit.php" method="post" enctype="multipart/form-data" name="uploadform">
<input type="hidden" name="talent_id" value="<?=$talent_id;?>" />
<input type="hidden" name="MAX_FILE_SIZE" value="2000000">
<fieldset>
<legend>
Production Talent Personal Information:
</legend>
<p><label for="first_name">Talent First Name:</label></p>
<input type="text" id="first_name" name="first_name" value="<?=$first_name;?>" />
<p><label for="last_name">Talent Last Name:</label></p>
<input type="text" id="last_name" name="last_name" value="<?=$last_name;?>" />
<p><label for="website">Talent Last Website:</label></p>
<input type="text" id="website" name="website" value="<?=$website;?>" />
</fieldset>
<br />
<fieldset>
<legend>
Production Talent Speciality:
</legend>
<select name="speciality">
<option value="1">Feature/TV DP</option>
<option value="2">Feature/TV PD</option>
<option value="3">Feature/TV Editors</option>
<option value="4">Feature/TV Costume designers</option>
<option value="5">Commercial/Music Video DP</option>
<option value="6">Commercial/Music Video PD</option>
<option value="7">Commercial/Music Video costume Designer/ Stylist </option>
</select>
</fieldset>
<br />
<fieldset>
<legend>
Production Talent File Upload:
</legend>
<p class="ins">To upload a file, if you're using a reasonably good Web browser, there should be a button marked Choose file or Browse, which will let you pick out a file on your hard drive, .pdf, .jpg. Please make sure that the file name is descriptive (e.g., fname_lname_resume.pdf or fname_lname_headshot.jpg). View your uploaded files: <a href="./upload/index.php" title="file download">Download Files</a> </p>
<p>File Types: .pdf, .jpg.</p>
<p><label for="Resume">Resume</label>
<input name="resume" type="file" class="box" id="resume" /></p>
<p><label for="Headshot">Headshot</label>
<input name="headshot" type="file" id="headshot" /></p>
<input name="update" type="submit" id="upload" value=" Add Talent " /><input type="reset" value="Reset" />
</fieldset>
</form>
<p><a href="./prod_admin.php">Back to production admin page</a> | <a href="./cms_index.php">Back to index page</a> </p>
</div>
</body>
</html>