Need help with browsing for files

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • orfiyus
    New Member
    • Jul 2007
    • 36

    Need help with browsing for files

    Hey

    I have a php script which has a browse button that lets the user pick the file. Once the file is picked it redirects to the same page outputting the name of the file picked as a string. The problem I am having is that the name of the file is not being printed to the screen. Can someone take a look to see wuts wrong with it?
    Thanks

    [PHP]<html>
    <body>

    <form enctype="multip art/form-data" action="browse. php" method="POST">
    <input type="hidden" name="MAX_FILE_ SIZE" value="100000" />
    Choose a file to upload: <input name="uploadedf ile" type="file" /><br />
    <input type="submit" value="submit" />
    </form>

    <?php
    echo("<br>This is browse.php<br>" );

    $file_name = $_REQUEST['uploadedfile'];

    echo("<br>This is the file that is selected (string)$file_n ame");
    ?>


    </body>
    </html>
    [/PHP]
  • Markus
    Recognized Expert Expert
    • Jun 2007
    • 6092

    #2
    Files arent passed through the POST or GET arrays, instead they are passed through the special FILES array.

    If you havent read a tutorial on file upload i suggest you take a look at one.

    The name of the file resides in the ['name'] key:
    [php]
    $file_name = $_FILES['uploadedfile']['name'];
    [/php]

    Comment

    Working...