Hello,
I am having a problem with this upload script it wont pull the basename of the file i am trying to upload and it wont upload the file... Ive used variations of the script before and they work fine.. alls i did with this one was change some variable names to fit the form... can someone help? please let me know.
<?php
//open database
include("../config.php");
include("../opendb.php");
//post form
$itemName = $_POST['itemName'];
$itemNum = $_POST['itemNum'];
$mainCat = $_POST['mainCat'];
$subCat = $_POST['subCat'];
$quantity = $_POST['quantity'];
$sumDesc = $_POST['sumDesc'];
$itemDesc = $_POST['itemDesc'];
$proImage = basename( $_FILES['proImage']['name']);
//validate and upload form
if(isset($_POST['submit'])) {
$uploaddir = $mainCat . '/' . $subCat . '/';
$file_path = $mainCat . '/' . $subCat . '/';
$uploaddir = $uploaddir . basename($_FILES['proImage']['name']);
echo '<pre>';
if (move_uploaded_file($_FILES['proImage']['tmp_name'], $uploaddir)) {
echo "File is valid, and was successfully uploaded.\n";
} else {
echo "Possible file upload attack!\n";
}
echo 'Here is some more debugging info for the file:';
print_r($_FILES);
print "</pre>";
mysql_query("INSERT INTO inventory (itemName, itemNum, mainCat, subCat, quantity, sumDesc, itemDesc, imageName, filePath) VALUES ('$itemName','$itemNum','$mainCat','$subCat','$quantity','$sumDesc','$itemDesc','$proImage','$file_path')");
}
?>
<!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=iso-8859-1" />
<title>Update Inventory</title>
</head>
<body>
<h3>Update Inventory</h3>
<span style="color:#FF0000">All fields required</span>
<form method="post" action="inventory.php">
<table>
<tr>
<td>Item name:</td>
<td><input type="text" name="itemName" size="35" value="<?php //print ; ?>" /></td>
</tr>
<tr>
<td>Item number:</td>
<td><input type="text" name="itemNum" size="35" value="<?php //print ; ?>" /></td>
</tr>
<tr>
<td>Category:</td>
<td>
<select name="mainCat">
<option value="guitar">Guitar</option>
<option value="drums">Drums</option>
</select>
</td>
</tr>
<tr>
<td>Sub-Category:</td>
<td>
<select name="subCat">
<option value="accessories">Guitar Accessories</option>
<option value="books">Guitar Books</option>
<option value="cases">Guitar Cases</option>
<option value="guitars">Guitars</option>
<option value="picks">Guitar Picks</option>
<option value="strings">Guitar Strings</option>
<option value="accessories">Drum Accessories</option>
<option value="books">Drum Books</option>
<option value="drums">Drums</option>
<option value="drumSets">Drum Sets</option>
<option value="sticks">Drum Sticks</option>
<option value="cymballs">Cymballs</option>
</select>
</td>
</tr>
<tr>
<td>Quantity:</td>
<td><input type="text" name="quantity" size="2" value="<?php //print ; ?>" /></td>
</tr>
<tr>
<td colspan="2">Summary description:</td>
</tr>
<tr>
<td colspan="2"><textarea name="sumDesc" cols="35" rows="5"><?php //print ; ?></textarea></td>
</tr>
<tr>
<td colspan="2">Item description:</td>
</tr>
<tr>
<td colspan="2"><textarea name="itemDesc" cols="35" rows="10"><?php //print ; ?></textarea></td>
</tr>
<tr>
<td>Upload image</td>
<td><input type="file" name="proImage" /></td>
</tr>
<tr>
<td colspan="2"><input type="submit" name="submit" value="Submit & Upload" /></td>
</tr>
</table>
</form>
</body>
</html>