Results 1 to 3 of 3

Thread: [Resolved] File Uploads and Arrays?

  1. #1

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256

    [Resolved] File Uploads and Arrays?

    I have a form somewhat like this:

    Code:
    <form action="index.php" method="post">
        1. <input type="file" name="f[]"><br>
        2. <input type="file" name="f[]"><br>
        3. <input type="file" name="f[]"><br>
    
        <input type="submit" value=" Send ">
    </form>
    Now, how can I tell how many, if any, of these include files?

    I tried something like:

    Code:
    echo count($_FILES['f']);
    //and:
    echo count($_POST['f']);
    But neither work.
    Last edited by The Hobo; Jul 24th, 2003 at 03:15 PM.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  2. #2

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    I guess I'm going to assume that I can't use arrays with file types. The following code works for the text type, but not the file:

    Code:
    <?php
        if (isset($_POST['submit'])) {
            echo $_FILES['my_file'][0]['type'] . '<br>';
            echo $_POST['my_text'][0];
        } else {
            echo '<form action="testupload.php" method="post" enctype="multipart/form-data">
                <input type="file" name="my_file[]">
                <br>
                <input type="text" name="my_text[]">
                <br>
                <input type="submit" name="submit" value=" Send ">
            </form>';
        }
    ?>
    My evil laugh has a squeak in it.

    kristopherwilson.com

  3. #3

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Ah ha!

    Code:
    $_FILES['my_file'][0]['type']; //should be:
    $_FILES['my_file']['type'][0];
    My evil laugh has a squeak in it.

    kristopherwilson.com

Posting Permissions

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



Click Here to Expand Forum to Full Width