why no $_POST[fupload] ?

Discussion in 'HTML' started by carlton, Aug 13, 2006.

  1. carlton

    carlton Guest

    When I run the following page, the foreach ($_POST as $key=>$value)
    lists the correct values for MAX_FILE_SIZE and password, but no value
    for fupload, why is the requested file not being sent? I have tried it
    with Firefox, Opera, IE, and Konqueror. all with the same result.
    I am running Mandriva 2006 with Apache 2.0.54
    T.I.A.,
    Carlton
    <html>
    <head>
    <title>Listing 9.15 A file upload script</title>
    </head>
    <SCRIPT language="php">
    <?php
    $file_dir = "/home/carlton/uploads";
    $file_url = "http://localhost/uploads";
    foreach ($_POST as $key=>$value)
    {
    print "\$_POST[\"$key\"] == $value<BR> ";
    }
    if ( isset( $fupload ) )
    {
    print "path: $fupload<br>";
    print "name: $fupload_name<br>\n";
    print "size: $fupload_size bytes<br>\n";
    print "type: $fupload_type<p>\n\n";
    if ( $fupload_type == "image/gif" )
    {
    copy ( $fupload, "$file_dir/$fupload_name") or die ("Couldn't copy");

    print "<img src=\"$file_url/$fupload_name\"><p>\n\n";
    }
    }
    else
    {
    print"<BOLD>First call to the page</BOLD>";
    }
    ?>
    </SCRIPT>
    <body>
    <form enctype="multipart/form-data" action="" method="POST">
    <input type="hidden" name="MAX_FILE_SIZE" value="51200">
    <input type="file" name="fupload"><br>
    x<input type="submit" value="Send file!">
    </form>
    </body>
    </html>
     
    carlton, Aug 13, 2006
    #1
    1. Advertising

  2. carlton

    Toby Inkster Guest

    carlton wrote:

    > When I run the following page, the foreach ($_POST as $key=>$value)
    > lists the correct values for MAX_FILE_SIZE and password, but no value
    > for fupload, why is the requested file not being sent?


    Same reason there's no $_COOKIE[fupload], $_GET[fupload], $_SERVER[fupload]
    or $_SESSION[fupload].

    The reason is: because that's not where uploaded files live.

    Uploaded files live in $_FILES.

    http://uk2.php.net/manual/en/features.file-upload.php

    --
    Toby A Inkster BSc (Hons) ARCS
    Contact Me ~ http://tobyinkster.co.uk/contact
     
    Toby Inkster, Aug 13, 2006
    #2
    1. Advertising

  3. carlton

    carlton Guest

    Toby Inkster wrote:
    > carlton wrote:
    >
    >
    >>When I run the following page, the foreach ($_POST as $key=>$value)
    >>lists the correct values for MAX_FILE_SIZE and password, but no value
    >>for fupload, why is the requested file not being sent?

    >
    >
    > Same reason there's no $_COOKIE[fupload], $_GET[fupload], $_SERVER[fupload]
    > or $_SESSION[fupload].
    >
    > The reason is: because that's not where uploaded files live.
    >
    > Uploaded files live in $_FILES.
    >
    > http://uk2.php.net/manual/en/features.file-upload.php
    >

    Thanks very much for the help, much appreciated. I had taken the code
    from a php text book, so I assumed it was OK.
    Carlton.
     
    carlton, Aug 14, 2006
    #3
  4. carlton

    Toby Inkster Guest

    carlton wrote:

    > php text book


    Bin it. PHP.net has all the information you need; and it's very well
    laid-out.

    --
    Toby A Inkster BSc (Hons) ARCS
    Contact Me ~ http://tobyinkster.co.uk/contact
     
    Toby Inkster, Aug 14, 2006
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mr. SweatyFinger
    Replies:
    2
    Views:
    2,224
    Smokey Grindel
    Dec 2, 2006
  2. Stef Mientki
    Replies:
    4
    Views:
    700
    Roy Smith
    Nov 15, 2010
  3. Steve Holden
    Replies:
    4
    Views:
    214
    Neil Cerutti
    Nov 12, 2010
  4. Stef Mientki
    Replies:
    2
    Views:
    287
    Paul Watson
    Nov 11, 2010
  5. Robert Oschler

    Access $_POST variables from Javascript?

    Robert Oschler, Aug 21, 2005, in forum: Javascript
    Replies:
    3
    Views:
    122
    |-|erc
    Aug 22, 2005
Loading...

Share This Page