SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Hybrid View

  1. #1
    SitePoint Enthusiast
    Join Date
    Oct 2006
    Location
    East Coventry, PA
    Posts
    54
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Empty $_FILES array with enctype="multipart/form-data"

    This is strange. I have a form to upload photos. Here is my form tag:

    <form enctype="multipart/form-data" action="<?$_SERVER["PHP_SELF"];?>" method="post">

    With the enctype="multipart/form-data" in the form tag, print_r($photos); returns nothing. If I remove the enctype, it shows the contents of my array.

    Not sure what to do here. Any help is greatly appreciated.

  2. #2
    rajug.replace('Raju Gautam'); bronze trophy Raju Gautam's Avatar
    Join Date
    Oct 2006
    Location
    Kathmandu, Nepal
    Posts
    4,013
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Show us your full HTML form and also possibly the script after your form is submitted.
    Mistakes are proof that you are trying.....
    ------------------------------------------------------------------------
    PSD to HTML - SlicingArt.com | Personal Blog | ZCE - PHP 5

  3. #3
    SitePoint Enthusiast
    Join Date
    Oct 2006
    Location
    East Coventry, PA
    Posts
    54
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok. Here is a little test form I created:

    HTML Code:
    <form enctype="multipart/form-data" action="test.php" method="post">
    <input type="file" name="photos[ ]"><br>
    <input type="file" name="photos[ ]"><br>
    <input type="file" name="photos[ ]"><br>
    <input type="file" name="photos[ ]"><br>
    <input type="submit">
    </form>
    Here is the code to display the file names:
    PHP Code:
    $photos $_POST['photos'];
    foreach (
    $photos as $s) {
      echo 
    "$s<br />";

    With the enctype in the form tag, it returns nothing. Without, it displays the file names.

  4. #4
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    Because files are not put in "_POST" they are contained in "_FILES"
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  5. #5
    SitePoint Enthusiast
    Join Date
    Oct 2006
    Location
    East Coventry, PA
    Posts
    54
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks logic_earth. That worked, I don't know how I missed that.


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
  •