I seem to run into so many issues when dealing with writing to directories. If someone could please look over this script, and tell me why it's not working, I'd be so appreciative.

Upon uploading the file from the form, I don't get anything.. It doesnt output any errors, it simply just refreshes.

Thanks, Lea

```
<?php include ('config.php');
 if( isset($_POST['submit']) ) {

$target = ''.$_SERVER['DOCUMENT_ROOT'].'/images/';
$target = $target . basename( $_FILES['photo']['name']) ;
$url = basename( $_FILES['photo']['name']) ;

if(move_uploaded_file($_FILES['photo']['tmp_name'], $target)) {
$moved =  "File has been moved to location $target";

$name = mysql_real_escape_string($_POST['photoname']);
mysql_query("INSERT INTO photos (photo_name, photo_image) VALUES ('$name',  '$url' )") or die(mysql_error());
$success = "Photo has been added!";

  } else {

$moved = "File has not been moved to $target";
$success = "Failed to upload:(";

  }

} ?>

<!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>Photo Upload</title>
<meta name="robots" content="index, follow" />
<meta name="keywords" content="" />
<meta name="description" content="" />
<link href="<?php echo $globalurl; ?>styles.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="holder">
<br /><br />
<b>Add a new photo</b>
<hr />
<br />
<b><?php echo "$success<br />"; ?>
<?php echo "$moved<br />"; ?></b>
  <form enctype="multipart/form-data" method="post" action="<?php echo $PHP_SELF; ?>">
    <table cellspacing="0" cellpadding="0" width="500px">
      <tbody>
        <tr>
          <td valign="top">Photo Name:</td>
          <td valign="top">
            <input type="text" name="photoname" /><br />
            <br />
            </td>
        </tr>
        <tr>
          <td valign="top">Photo:</td>
          <td valign="top">
  <input type="file" name="photo"><br />
            <br />
            </td>
        </tr>
      </tbody>
    </table>
    <input type="submit" value="submit" />
  </form>
</div>
</body>
</html>

```