Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Sep 2011
    Posts
    13
    Thanks
    3
    Thanked 0 Times in 0 Posts

    need help with code

    am getting this error help me :

    Notice: Undefined index: file in C:\xampp\htdocs\series\script\page2.php on line 2

    Notice: Undefined index: file in C:\xampp\htdocs\series\script\page2.php on line 6

    with this code :

    <?php
    $name = $_FILES['file']['name'];
    //$size = $_FILES['file']['size'];
    //$type = $_FILES['file']['type'];

    $tmp_name = $_FILES['file']['tmp_name'];
    if (isset($name)) {
    if(!empty($name)) {
    echo 'OK.!!';

    } else {
    echo 'Please choose a file';

    }
    }


    ?>
    <form action="page2.php" method="POST" enctype="multipart/form-data">
    <input type="file" name="file"><br /><br />
    <input type="submit" value="Submit">
    </form>

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,852
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    Try
    PHP Code:
    <?php
    if(isset($_FILES['file'])){
    $name $_FILES['file']['name'];
    //$size = $_FILES['file']['size'];
    //$type = $_FILES['file']['type'];

    $tmp_name $_FILES['file']['tmp_name'];

    if(!empty(
    $name)) {
    echo 
    'OK.!!';

    } else {
    echo 
    'Please choose a file';

    }
    }
    ?>
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • Users who have thanked abduraooft for this post:

    Thenewphp (09-18-2011)

  • #3
    Senior Coder
    Join Date
    Jul 2011
    Posts
    1,226
    Thanks
    3
    Thanked 171 Times in 171 Posts
    Show us more of the code. The error means there's no index 'file' in the $_FILES array. There could be multiple reasons for this, but we wont know for sure until we see the full code.

  • #4
    New Coder
    Join Date
    Sep 2011
    Posts
    13
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Thank you very much man


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •