All of the data is writing to the database just file, but the file never uploads. My directory is CHMOD 777, so I'm thinking my code must be busted in some area. If you could take a look and tell me what you think, I'd be appreciative.
Here is my control file.
Code: Select all
<?php
if ($_POST['action'] == 'addfilemanager')
{
$table = "filemanager";
$title = $_POST['title'];
$leadin = $_POST['leadin'];
$file = $_FILES['file']['name'];
if (($_FILES['file']['type'] == 'application/pdf') && ($_FILES['file']['size'] < 100000))
{
echo '<strong>' . 'Uploading ' . $_FILES['file']['name'] . ' (' . $_FILES['file']['type'] . ', ' . ceil($_FILES['file']['size'] / 1024) . ' Kb)' . '</strong>' . '<br />';
if (file_exists('/files/' . $_FILES['file']['name']))
{
echo "<p class="error">". $_FILES['file']['name']." already exists.<br />";
echo "Please rename the file and try again.</p>";
}
else
{
move_uploaded_file($_FILES['file']['tmp_name'], '/files/' . $_FILES['file']['name']);
echo "<p class="error">The file has been uploaded successfully</p>";
}
}
else
{
echo "<p class="error">This site only accepts .pdf files only.</p>";
}
$query = "INSERT into $table values (NULL,'$title','$leadin','$file')";
$result = mysql_query($query);
// $p is the result page
$p = 9; //fileadd.inc.php
};
?>Code: Select all
<div id="maincontent">
<form action="<?PHP echo $PHP_SELF ?>" method="post" enctype="multipart/form-data" name="form">
<h2>Add A File:</h2>
<h3>Title:</h3>
<p>(The main caption of the file.)</p>
<p><textarea name="title" cols="60" id="title" rows="1"><?php echo $title ?></textarea></p>
<h3>Lead In Text:</h3>
<p>(Description of the file.)</p>
<p><textarea name="leadin" cols="60" id="leadin" rows="3"><?php echo $leadin ?></textarea></p>
<h3>File Upload:</h3>
<p><input type="file" name="file" value="<?php echo $file ?>" /></p>
<p align="center"><input name="action" type="hidden" value="addfilemanager" />
<input name="Submit" type="submit" id="Submit" value="Add A File" />
<input name="Reset" type="reset" id="Reset" value="Reset"></p>
</form>
</div>Thanks!