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 5 of 5
  1. #1
    New Coder
    Join Date
    Sep 2011
    Posts
    13
    Thanks
    3
    Thanked 0 Times in 0 Posts

    need help with file_exist

    Gettin this error: Fatal error: Call to undefined function file_exist() in C:\xampp\htdocs\series\script\page2.php on line 5

    With this:

    PHP Code:
    <?php

    $filename 
    'files.txt';

    if (
    file_exist($filename)) {
       echo 
    'File already exist. ';
    } else {
      
    $handle fopen($filename'w');
      
    fwrite($handle'welcome man');
      
    fclose($handle);
    }
    Last edited by Inigoesdr; 09-18-2011 at 05:40 PM.

  • #2
    New Coder
    Join Date
    Apr 2010
    Location
    Norfolk, England
    Posts
    63
    Thanks
    1
    Thanked 14 Times in 14 Posts
    Hi Thenewphp

    its file_exists()

    with and s

    just to be clear its 'exists' not 'exist'
    //Improvement in coding is iterative, each 'failure' is just the next step on your learning curve, some knowledge and logic can get you a long way.//

  • Users who have thanked thesam101 for this post:

    Thenewphp (09-18-2011)

  • #3
    New Coder
    Join Date
    Sep 2011
    Posts
    13
    Thanks
    3
    Thanked 0 Times in 0 Posts
    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>

  • #4
    New Coder
    Join Date
    Apr 2010
    Location
    Norfolk, England
    Posts
    63
    Thanks
    1
    Thanked 14 Times in 14 Posts
    Hi again Thenewphp

    When are you getting that error? Before you submit the form? Or after? or Both?

    There will be nothing in $_FILES until after you submit the form.
    //Improvement in coding is iterative, each 'failure' is just the next step on your learning curve, some knowledge and logic can get you a long way.//

  • #5
    Senior Coder
    Join Date
    Jul 2011
    Posts
    1,226
    Thanks
    3
    Thanked 171 Times in 171 Posts
    @thesam101: Thenewphp also started a new thread for this new problem, and it got resolved in that thread. He wasn't checking for the $_FILES isset() (basically what you've just said).

  • Users who have thanked BluePanther for this post:

    thesam101 (09-18-2011)


  •  

    Posting Permissions

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