SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Wizard Goof's Avatar
    Join Date
    Feb 2001
    Location
    Pittsburgh, PA
    Posts
    1,154
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Why isn't this script receiving the file?

    Ok, I just have a very simple test setup here:
    http://www.nathanrutman.com/temp/sim...load-test.html

    simple-upload-test.html:
    Code HTML4Strict:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>PHP Form/Email Test</title>
     
    <style type="text/css">
        label {
            display: block;
        }
     
        input, textarea {
            display: block;
        }
    </style>
     
    </head>
     
    <body>
     
    <form action="simple-exec.php" method="post">
        <p><label>Attachment: <input type="file" name="thefile"></label></p>
        <p><input type="submit"></p>
    </form>
     
    </body>
    </html>

    simple-exec.php:
    Code PHP:
    <?php
     
    $fileatt =            $_FILES['thefile']['tmp_name'];
    $fileatt_type =        $_FILES['thefile']['type'];
    $fileatt_name =        $_FILES['thefile']['name'];
     
    if (is_uploaded_file($fileatt)) {
        echo "file received";
    } else {
        echo "file not received";
    }
     
    ?>

    It comes back, "file not received"...shouldn't this be fairly simple? :-)

    Thanks!
    -Nate
    Nathan Rutman
    A slightly offbeat creative.

  2. #2
    Worship the Krome kromey's Avatar
    Join Date
    Sep 2006
    Location
    Fairbanks, AK
    Posts
    1,621
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You're missing the enctype="multipart/form-data" attribute in your form. As per the PHP manual: http://www.php.net/manual/en/features.file-upload.php
    PHP questions? RTFM
    MySQL questions? RTFM

  3. #3
    SitePoint Enthusiast
    Join Date
    Jun 2007
    Posts
    45
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    it should be the attribute enctype="multipart/form-data", for the file-upload type form, it can be a issue.



    Try
    Code PHP:
     print_r($_FILES);
    -> this will show you if it is something in your file array.

  4. #4
    SitePoint Wizard Goof's Avatar
    Join Date
    Feb 2001
    Location
    Pittsburgh, PA
    Posts
    1,154
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ahh, thanks guys.
    Nathan Rutman
    A slightly offbeat creative.


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
  •