I am trying to write a simple php program that will up load files smaller then 200000000 bytes to my website, but I keep getting an error when I try to run it
the initial HTML code is:

    <html>
<body>

<form action="upload.php" method="post"
enctype="multipart/form-data">
<label for="file">Filename:</label>
<input type="file" name="file" id="file" /> 
<br />
<input type="submit" name="submit" value="Submit" />
</form>

</body>
</html>

and then the following is the php code:

<?php
if (($_FILES["file"]["size"] < 200000000))
 {
    if ($FILES["file"]["error"] > 0)
        {
        echo "Return Code: " . $_FILES["file"] ["error"] . "<br />";
        }
    else
        {
        $Size = ($_FILES["files"]["size"]/ 1024);
        if ($Size > 1000)
            {
            $Size= $Size/1000;
            $type = "Mb";
            }
        else 
            {
            $type= "Kb";
            }

        echo "Upload: " . $_FILES["file"]["name"] . "<br />";
        echo "Type: " . $_FILES["file"]["type"] . "<br />";
        echo "Size: " . $Size . " " . $type . "<br />";
        echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";
        if (file_exists("stuff/" . $_FILES["file"] ["name"] ))
            {
            echo $_FILES["file"]["name"] . " already exist. ";
            }
        else
            {


            move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $_FILES["file"]["name"]);
            echo "Stored in: " . "stuff/" . $_FILES["file"] ["name"];
            }
        }
    }
else
    {
    header("Location: http://www.doled.org/upload/uhuh.html");
    }
?>

which when I run on line gives me the error
"Upload: balloon08.gif
Type: image/gif
Size: 0 Kb
Temp file: /usr/local/tmp/phpe96Gqh

Warning: move_uploaded_file(upload/balloon08.gif) [function.move-uploaded-file]: failed to open stream: No such file or directory in /home/.aspen/mesamb1/doled.org/upload/upload.php on line 32

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/usr/local/tmp/phpe96Gqh' to 'upload/balloon08.gif' in /home/.aspen/mesamb1/doled.org/upload/upload.php on line 32
Stored in: stuff/balloon08.gif"

which makes no since to me and I would like to fix, any advice would be greatly appreciated

You need to look in your php.ini file and make sure you have a writeable directory for uploads. It is a temp directory for uploads to the server. On Linux, it is usually /tmp but can be almost anywhere that the web server has write access.

Change the php.ini and restart the web server.

I changed the name of the place on my server where I wanted the file to go and that seems to have done the trick, thanks for your help khess

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.