File Manipulation Code

  Home arrow File Manipulation Code arrow Dir 2 Box
FILE MANIPULATION CODE

Dir 2 Box
By: Codewalkers
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2002-01-18

    Table of Contents:

     
     

    SEARCH CODEWALKERS

    TOOLS YOU CAN USE

    advertisement
    This function will read a directory and put the result into a listbox. So you can choose a file from that listbox.

    By : wibi

    <?
    /********************************************************************
    * drop-down-menu - form field function.
    * function that read directory content and
    * return the result list as drop-down-menu
    * Syntax :
    * - string dir2box(string path, string name, string selected-file);
    *
    * Copyright (C) 2001 Wibisono Sastrodiwiryo.
    * This program is free software licensed under the
    * GNU General Public License (GPL).
    *
    * CyberGL => Application Service Provider
    * http://www.cybergl.co.id
    * office@cybergl.co.id
    *
    * $Id: dir2box.php3,v 0.1 2001/07/5 19:42:20 wibi Exp $
    *********************************************************************/

    function dir2box($path, $name, $default="") {
    $result="<select name=\"$name\" size=1>\n";
    $handle=opendir("$path");
    while ($file = readdir($handle)) {
    if ($file == $default) {$selected="selected";} else {$selected="";}
    if ($file != "." and $file !="..") {$result.="<option value=\"$file\" $selected>$file</option>\n";}
    }
    closedir($handle);
    $result.="</select>\n";
    return $result;
    }
    ?>

    /* example */
    <?
    require("dir2box.php3");
    $default="index.php3";
    $path="/home/cybergl.co.id/htdocs";
    ?>
    <form>
    <p>
    Files :
    <?
    echo dir2box($path, "directory", $default);
    ?>
    <p>
    </form>
    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

    More File Manipulation Code Articles
    More By Codewalkers

    blog comments powered by Disqus

    FILE MANIPULATION CODE ARTICLES

    - Bandwidth Control with pure PHP
    - Eazy Gallery
    - file_get_contents for PHP < 4.3.0
    - PHP Class: Image Snapshot 1.3
    - Universal downloader
    - Image Gallery v2.0
    - Free/Used Disk Space
    - Directory Lister
    - Directory image view, with selective hidden
    - Move or Copy a Directory (and files and sub ...
    - Ensure_Sub_Directory_Exists
    - Wedit
    - Form Examples Text Boxes to Drop Downs
    - myFiles
    - List files in a directory, no subdirectories


    © 2003-2012 by Developer Shed. All rights reserved. DS Cluster 4 - Follow our Sitemap