treehouse : what would you like to learn today?
Web Design Web Development iOS Development

[Solved] PHP nightmare!

  • Here is my PHP script:
    <?php
    if (isset($_FILES ['documents'])) {
    $errors=array () ;
    $allowed_ext= array ('doc','docx','ppt','pptx','pages','html','els','elsx','numbers');

    $file_name= $_FILES ['documents'] ['name'];
    $file_ext= strtolower(end(explode ('.', $file_name)));
    $file_size=$_FILES ['documents'] ['size'];
    $file_tmp= $_FILES ['documents'] ['tmp_name'];

    if (in_array($file_ext, $allowed_ext) === false) (
    $errors[] ='Extension not allowed';
    )

    }
    ?>

    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="utf-8" />
    <title></title>
    </head>
    <body>
    <form action="" method="post" enctype="multipart/form-data">
    <p>
    <input type="file" name="documents"/>
    <input type="submit" value="Upload"/>
    </p>
    </form>
    </body>
    </html>

    I keep on geting error's and I don't know why. I've been starring at this for hours :(
  • If statements use curly braces, not round brackets.

    {}

    not

    ()
  • Thank you so much! This was a massive help