SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Addict
    Join Date
    Aug 2004
    Location
    Chicago
    Posts
    296
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    $_FILES Empty After File Upload

    I'm using this form to try to upload a file.

    HTML Code:
    <!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01//EN' 
    'http://www.w3.org/TR/html4/strict.dtd'>
    <html>
     <head>
      <title>Music Vids</title>
     </head>
     <body>
      <form enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
       Section: <input type="text" name="section"><br />
       <input type="hidden" id="MAX_FILE_SIZE" name="MAX_FILE_SIZE" value="102400000" />
       <input type="file" id="userfile" name="userfile" /><br />
       <input type="hidden" id="action" name="action" value="upload" />
       <input type="submit" value="Submit" />
      </form>
     </body>
    </html>
    Something wasn't working, so I had the form's action go to printr.php which basically prints (using print_r) out all the PHP superglobals. That returns nothing, so I'm completely lost.

    I know it's not the MAX_FILE_SIZE, since the max upload file size is 100M, if that helps.
    Why's (Poignant) Guide to Ruby
    learn ruby with foxes, wizards, and chunky bacon

  2. #2
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,807
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    Hi, the variables passed from the posted form when you use a file upload are passed in a seperate global $_FILES.

    You can use that to find out information about the file.

    on your print_r page, echo the $_FILES array as well as the $_POST array.

    Cheers

    SpikeZ

    PS Over 30 and trying to hide it!
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  3. #3
    SitePoint Addict
    Join Date
    Aug 2004
    Location
    Chicago
    Posts
    296
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is what I'm using for printing out all the superglobals, and I'm get nothing with it . . .

    PHP Code:
    <html><body><pre>
    <?php
    # Yes, I am that lazy :p
    function br() { echo '<br />'; }

    echo 
    'post: ';
    print_r($_POST);
    br();
    echo 
    'get: ';
    print_r($_GET);
    br();
    echo 
    'cookie: ';
    print_r($_COOKIE);
    br();
    echo 
    'files: ';
    print_r($_FILES);
    br();
    echo 
    'request: ';
    print_r($_REQUEST);
    ?></pre></body></html>
    Why's (Poignant) Guide to Ruby
    learn ruby with foxes, wizards, and chunky bacon

  4. #4
    SitePoint Enthusiast ada80ro's Avatar
    Join Date
    Apr 2005
    Posts
    64
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try this:

    Code:
    <?php
    if(isset($_POST['submit'])){
            echo '<pre>';
            print_r($_FILES);
            echo '</pre>';
            }
    ?>
    <!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01//EN' 'http://www.w3.org/TR/html4/strict.dtd'>
    <html>
    
    <head>
     <title>Music Vids</title>
    </head>
    
    <body>
     <form enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
     Section: <input type="text" name="section"><br />
     <input type="hidden" id="MAX_FILE_SIZE" name="MAX_FILE_SIZE" value="102400000" />
     <input type="file" id="userfile" name="userfile" /><br />
     <input type="hidden" id="action" name="action" value="upload" />
     <input type="submit" value="Submit" name="submit"/>
     </form>
    </body>
    </html>

  5. #5
    SitePoint Addict
    Join Date
    Aug 2004
    Location
    Chicago
    Posts
    296
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, that works, and I just realized that my other form works too.

    It seems that PHP can't upload .mpg files. *bangs head on desk*

    Sorry, everyone
    Why's (Poignant) Guide to Ruby
    learn ruby with foxes, wizards, and chunky bacon


Bookmarks

Posting Permissions

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