file upload not showing up in /tmp linux

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jim

    file upload not showing up in /tmp linux

    I'm having huge problems with a web server not putting the uploaded
    file in the /tmp

    here is my code can some one please point me in the right
    direction?I'm thinking i've
    done something with wrong with apache but can't find out what.

    ---- up.html ----
    <HTML><BODY>
    <FORM method="POST" enctype="multip art/form-data" action="./up.php">
    <input type="hidden" name="MAX_FILE_ SIZE" value="10000000 00">
    <input type=file name=fupload>
    <INPUT type="submit">
    </FORM>
    </BODY>
    </HTML>
    ---- up.html ----


    ---- up.php ----
    <HTML><BODY>
    <?php
    echo "main hi $fupload<BR>";
    if( isset($fupload) ){
    echo "isset found hi $fupload_name<B R>";
    }
    ?>
    </BODY>
    </HTML>
    ---- up.html ----


    ---- output from a file uploaded of 120k----

    <HTML><BODY>
    main hi <BR></BODY>
    </HTML>
    ---- output ----
  • John Smith

    #2
    Re: file upload not showing up in /tmp linux

    Hi Jim,

    How PHP handle's uploaded files is quite different to normal variable
    submission (which isn't mentioned in the PHP documentation very well).

    $fupload won't be a variable containing the contents of the file you've
    uploaded, but an array of file information in the global $_FILES array
    (I don’t code PHP with global variables on).

    So for:

    <FORM method="POST" enctype="multip art/form-data" action="./up.php">
    <input type="hidden" name="MAX_FILE_ SIZE" value="10000000 00">
    <input type="file" name="fupload">
    <INPUT type="submit">
    </form>

    To check if a person has selected a file, and submitted, then print the
    file contents out, you would require the following PHP (for example).

    <?php

    //
    // Check if a file has attached ('none' needed for IE compatability)
    //
    if ( (!empty($_FILES['fupload']['tmp_name']) ) &&
    $_FILES['fupload']['tmp_name'] != 'none' )
    {

    $file_content = addslashes(frea d(fopen($_FILES['fupload']['tmp_name'],
    'r'), filesize($_FILE S['fupload']['tmp_name']) )); // Read File

    echo $file_content; // Echo it

    }
    else
    {
    echo 'No file was submitted';
    }

    ?>

    Btw, $_FILES['fupload']['tmp_name'] returns the name/path of the file as
    it's temporarily stored on the servers FS, so having a

    echo $_FILES['fupload']['tmp_name'];

    would return something like

    /tmp/php8329x9

    Ovbiously in the $_FILES['fupload'], the 'fupload' corresponds to the
    name of the form file bit in your form, so you could have multiple
    uploads on the one form with $_FILES['fuploadwhateve r'],
    $_FILES['fupload3'] etc.. corresponding to a:

    <input type="file" name="fupload3" >
    <input type="file" name="fuploadwh atever">


    Hope this helps.
    Grant


    Jim wrote:
    [color=blue]
    > I'm having huge problems with a web server not putting the uploaded
    > file in the /tmp
    >
    > here is my code can some one please point me in the right
    > direction?I'm thinking i've
    > done something with wrong with apache but can't find out what.
    >
    > ---- up.html ----
    > <HTML><BODY>
    > <FORM method="POST" enctype="multip art/form-data" action="./up.php">
    > <input type="hidden" name="MAX_FILE_ SIZE" value="10000000 00">
    > <input type=file name=fupload>
    > <INPUT type="submit">
    > </FORM>
    > </BODY>
    > </HTML>
    > ---- up.html ----
    >
    >
    > ---- up.php ----
    > <HTML><BODY>
    > <?php
    > echo "main hi $fupload<BR>";
    > if( isset($fupload) ){
    > echo "isset found hi $fupload_name<B R>";
    > }
    > ?>
    > </BODY>
    > </HTML>
    > ---- up.html ----
    >
    >
    > ---- output from a file uploaded of 120k----
    >
    > <HTML><BODY>
    > main hi <BR></BODY>
    > </HTML>
    > ---- output ----[/color]

    Comment

    • Jim

      #3
      Re: file upload not showing up in /tmp linux

      Absolutly Awesome thanks a ton.

      Comment

      Working...