Well ok here is a part of the script. It's purpose is to allow users to upload images. I am not going to post the whole thing (it's really long) but a snippet of where I get the problems
//Check if the individual game's folder exists
if(is_dir($upload_dir . $_SESSION['game_id']))
{
$new_dir = $upload_dir . $_SESSION['game_id'] . '/';
}
//If it doesn't, create the folder
else
{
//Make the folder
mkdir($upload_dir . $_SESSION['game_id'], 0777);
//New directories location
$new_dir = $upload_dir . $_SESSION['game_id'] . '/';
//CHMOD to make sure permissions are changed
chmod($new_dir, 0777);
//Copy protector file
copy(FULL_PATH . $GLOBAL['misc'] . 'index.htm', $new_dir . 'index.htm');
}
if(file_exists($new_dir . $new_name))
{
unset($sql);
unset($query);
//If the upload afterall didn't work, delete the file from database
$sql = "DELETE ";
$sql.= "FROM ";
$sql.= "boxart ";
$sql.= "WHERE ";
$sql.= "file = '" . $new_dir . $new_name . "'";
$query = mysql_query($sql);
unlink($file);
unset($_FILES);
echo '<p><font color="#FF0000">';
echo 'The file could not be uploaded! (Filesystem Error 1)';
echo '</font></p>';
}
else
{
if(move_uploaded_file($file, $new_dir . $new_name))
{
echo '<p>';
echo 'Your boxart was succesfully uploaded.';
echo '</p>';
echo '<p>';
echo '<strong><a href="content.php?act=boxart">Click here</a></strong> to go to the boxart control panel.';
echo '</p>';
}
else
{
unset($sql);
unset($query);
//If the upload afterall didn't work, delete the file from database
$sql = "DELETE ";
$sql.= "FROM ";
$sql.= "boxart ";
$sql.= "WHERE ";
$sql.= "file = '" . $new_name . "'";
$query = mysql_query($sql);
unlink($upload_dir . $new_name);
unlink($file);
unset($_FILES);
echo '<p><font color="#FF0000">';
echo 'The file could not be uploaded! (Filesystem Error 2)';
echo '</font></p>';
}
}