• I am trying to do a simple file upload to a production server. I’m using standard page code as follows:

    <html>
    <body>

    <form action=”upload_file.php” method=”post”
    enctype=”multipart/form-data”>
    <label for=”file”>Filename:</label>
    <input type=”file” name=”file” id=”file” />

    <input type=”submit” name=”submit” value=”Submit” />
    </form>

    </body>
    </html>

    <?php
    if ((($_FILES[“file”][“type”] == “image/gif”)
    || ($_FILES[“file”][“type”] == “image/jpeg”)
    || ($_FILES[“file”][“type”] == “image/pjpeg”))
    && ($_FILES[“file”][“size”] < 20000))
    {
    if ($_FILES[“file”][“error”] > 0)
    {
    echo “Return Code: ” . $_FILES[“file”][“error”] . “
    “;
    }
    else
    {
    echo “Upload: ” . $_FILES[“file”][“name”] . “
    “;
    echo “Type: ” . $_FILES[“file”][“type”] . “
    “;
    echo “Size: ” . ($_FILES[“file”][“size”] / 1024) . ” Kb
    “;
    echo “Temp file: ” . $_FILES[“file”][“tmp_name”] . “
    “;

    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
    {
    echo “Invalid file”;
    }
    ?>

    The error I’m getting is:

    Warning: move_uploaded_file(upload/BRAVE.jpg) [function.move-uploaded-file]: failed to open stream: No such file or directory

    and

    Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move ‘C:\wamp\tmp\php189.tmp’ to ‘upload/BRAVE.jpg’

    This code used to work for a couple of months but no longer works.
    Is there anyway to change the c: directory that is automatically assigned (in this case ” C:\wamp\tmp\php189.tmp”). The directory exists but the temp file is not created.

    Any help would be greatly appreciated,
    Bill

  • The topic ‘file upload problem’ is closed to new replies.