File upload problem

Discussion in 'PHP' started by barnes, Apr 20, 2007.

  1. #1
    fileupload.html
    <html>
    <body>
    <form name="frmname"action="upload.php" method="post">
    upload your file:<input type="file" name="file"><br>
    <input type="submit" name="submit" value="submit">
    </form>
    </body>
    </html>


    upload.php

    <?php
    if ($_FILES["file"]["error"] > 0)
    {
    echo "Error:". $_FILES["file"]["error"] ."<br>";
    }
    else
    {
    echo "upload:". $_FILES["file"]["name"] ."<br>";
    echo "type:". $_FILES["file"]["type"] ."<br>";
    echo "size:". ($_FILES["file"]["size"]/1024) ."kb<br>";
    echo "stored in:". $_FILES["file"]["tmp_name"] ."<br>";
    }
    ?>

    when i uploading some text file and click submit button the following o/p is showing:
    Notice: Undefined index: file in c:\easyphp1-8\www\upload.php on line 2

    Notice: Undefined index: file in c:\easyphp1-8\www\upload.php on line 8
    upload:

    Notice: Undefined index: file in c:\easyphp1-8\www\upload.php on line 9
    type:

    Notice: Undefined index: file in c:\easyphp1-8\www\upload.php on line 10
    size:0kb

    Notice: Undefined index: file in c:\easyphp1-8\www\upload.php on line 11
    stored in:
    how to reslove this problem..thanks in advance..
     
    barnes, Apr 20, 2007 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    Your HTML for is missing the encryption.
    
    <form name="frmname"action="upload.php" method="post" encrtpy="multipart/form-data">
    
    HTML:
     
    nico_swd, Apr 20, 2007 IP