Simple PHP upload form not working
<p>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.</p>

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

<p>Thanks, Lea</p>

<pre><code>&lt;?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:(";

  }

} ?&gt;

&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; 
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /&gt;
&lt;title&gt;Photo Upload&lt;/title&gt;
&lt;meta name="robots" content="index, follow" /&gt;
&lt;meta name="keywords" content="" /&gt;
&lt;meta name="description" content="" /&gt;
&lt;link href="&lt;?php echo $globalurl; ?&gt;styles.css" rel="stylesheet" type="text/css" /&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div class="holder"&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;b&gt;Add a new photo&lt;/b&gt;
&lt;hr /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;?php echo "$success&lt;br /&gt;"; ?&gt;
&lt;?php echo "$moved&lt;br /&gt;"; ?&gt;&lt;/b&gt;
  &lt;form enctype="multipart/form-data" method="post" action="&lt;?php echo $PHP_SELF; ?&gt;"&gt;
    &lt;table cellspacing="0" cellpadding="0" width="500px"&gt;
      &lt;tbody&gt;
        &lt;tr&gt;
          &lt;td valign="top"&gt;Photo Name:&lt;/td&gt;
          &lt;td valign="top"&gt;
            &lt;input type="text" name="photoname" /&gt;&lt;br /&gt;
            &lt;br /&gt;
            &lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;td valign="top"&gt;Photo:&lt;/td&gt;
          &lt;td valign="top"&gt;
  &lt;input type="file" name="photo"&gt;&lt;br /&gt;
            &lt;br /&gt;
            &lt;/td&gt;
        &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
    &lt;input type="submit" value="submit" /&gt;
  &lt;/form&gt;
&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>
