PHP file upload
<p>Hey guys I'm trying to make a file uploader on my website and I have followed a tutorial but it doesn't seem to work. I am currently using the following code:</p>

<pre><code>    &lt;?php
session_start();
include('../../config/config.php');

if(isset($_SESSION['id'])) {

$filename = $_FILES["file"]["name"];
$filesize = $_FILES["file"]["size"];

$name = $_POST['name'];
$price = "$" . $_POST['price'];
$photo = $_POST['file'];
$description = nl2br($_POST['description']);

$file_ext = getExt($photo);

  if ($_FILES["file"]["error"] &gt; 0)
    {
    echo "Return Code: " . $_FILES["file"]["error"] . "&lt;br /&gt;";
    }
  else
    {
    echo "Upload: " . $_FILES["file"]["name"] . "&lt;br /&gt;";
    echo "Type: " . $_FILES["file"]["type"] . "&lt;br /&gt;";
    echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb&lt;br /&gt;";
    echo "Temp file: " . $_FILES["file"]["tmp_name"] . "&lt;br /&gt;";

    if (file_exists("upload/" . $_FILES["file"]["name"]))
      {
      echo $_FILES["file"]["name"] . " already exists. ";
      }
    else
      {
      move_uploaded_file($_FILES["file"]["tmp_name"],"/upload/" . $_FILES["file"]["name"]);
      echo "Stored in: " . "upload/" . $_FILES["file"]["name"];
      }
    }

} else {

header("Location: ../../index.php");

}


?&gt;
</code></pre>

<p>I seems to create the temporary file fine but I am not sure why I won't move it. Right now I am testing the code with image files.</p>

<p>Also here is my form code:</p>

<pre><code>                &lt;form method="post" action="actions/add.php" enctype="multipart/form-data"&gt;
                    &lt;/br&gt;
                    Listing name: &lt;input type="text" name="name" /&gt;&lt;/br&gt;&lt;/br&gt;
                    Listing Photo: &lt;input type="file" name="file"/&gt;&lt;/br&gt;&lt;/br&gt;
                    Price: $&lt;input type="text" name="price"/&gt;&lt;/br&gt;&lt;/br&gt;
                    Information:&lt;/br&gt;
                    &lt;textarea class="add" name="description"&gt;&lt;/textarea&gt;

                    &lt;/br&gt;&lt;/br&gt;

                    &lt;input class="add" type="submit" name="submit"/&gt;
                &lt;/form&gt;
</code></pre>

<p>EDIT:</p>

<p>Some errors:</p>

<pre><code>    Warning: move_uploaded_file(upload/Corgi 004.jpg) [function.move-uploaded-file]: failed to open stream: No such file or directory in /home/stationr/public_html/admin/actions/add.php on line 42

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/chroot/tmp/phpLXObbt' to 'upload/Corgi 004.jpg' in /home/stationr/public_html/admin/actions/add.php on line 42
</code></pre>

<p>Thanks for any help.</p>
