Error uploading image

From: Adam Rumpke (goldstonrumpke_at_hotmail.com)
Date: 03/29/04


Date: 29 Mar 2004 00:44:44 -0800

Thank those who e-mailed me back on my last question. I am now writing
a script from a tutorial I found at "HotScripts" ... I am trying to
upload an image from html form to apache. I chmod(ed) the directory
and typed in the right path name but I am confused on why this isnt
working.

HTML FORM
---------
<html>
<head>
    <title>Uploading a File</title>
</head>
<body>
<form action="upload_img.php" enctype="multipart/form-data"
method="post">
<input type="file" name="myfile"><br><br>
<input type="submit" value="upload"><br>
</form>
</body>
</html>

PHP HANDLER
------------
<?

    // name of the directory that your uploads will be kept in
    $dirname = "images";

    // the path that the uploads directory will be placed in
    define(PATH, "/var/www/html/building/images/");
     
    // gets just the file name and extension from the file input
    // in the form
    $filename = $myfile_name;
     
    // check if they actually placed something in the file input
    if ($filename != "")
    {
        // check if the directory exists
        // if it doesnt exist, make the directory
        if (!$dir = @opendir(PATH.$dirname))
            // make the directory (sets chmod to 700)
            mkdir(PATH.$dirname, 0700) or die("<b>Error:</b> could not
make directory.");
             
        // copy the file from the temporary upload position to where
you want it
        copy($myfile, PATH.$dirname."/".$filename) or
die("<b>Error:</b> could not copy file.");
         
        // delete the temporary uploaded file
        unlink($myfile) or die("<b>Error:</b> could not delete
uploaded file.");
         
        // tell them it worked
        echo "File uploaded successfully.";
    }
    else
    {
        // tell them to browse for a file
        echo "You must select a file to upload.";
    }

?>

I am still learning and I cant see why this tutorial doesnt work for
me. I keep getting the error message that says "You must select a file
to upload." I did select a file. Seriously, any help would be welcomed
...

- Adam



Relevant Pages

  • Error uploading image
    ... a script from a tutorial I found at "HotScripts" ... ... upload an image from html form to apache. ...
    (php.general)
  • Re: Maximum file size that can be handles with a PHP script
    ... I am currently trying to debug a script written by my predecessor. ... Basically I have an HTML form that is used to upload a file that is ... It has been in frequent use but I ... When I try to upload the file using the script, ...
    (comp.lang.php)
  • Maximum file size that can be handles with a PHP script
    ... I am currently trying to debug a script written by my predecessor. ... Basically I have an HTML form that is used to upload a file that is ... It has been in frequent use but I ...
    (comp.lang.php)
  • Re: automated upload with PHP
    ... have your script one once per day and upload any images not already ... tiffs and the php script, ... // request local file read permission ...
    (comp.lang.php)
  • [UNIX] Cobalt Raq XTR Combination Attack (Remote/Local)
    ... Due to an authentication bug in the upload Handler, ... The next problem lies in the base64 encoding of the filename, ... After the symlinks have been created (script to create base64 symlink is ...
    (Securiteam)