SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    HAHA!
    Join Date
    Mar 2006
    Posts
    656
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question parsing all files in a folder

    Here is what I want to do. Have a number of images in a folder. Put the file in there (more advanced version would let me specify folder path of course) and then when I click parse files it will parse all the file names and allow me to upload them to a db?
    Cheap web hosting directory listing the cheapest web hosting

    Submit articles to an article directory

  2. #2
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Something like this maybe?
    PHP Code:
    <?php
    try
    {
        
    $aFiles = array();
        foreach (new 
    DirectoryIterator(realpath(dirname(__FILE__))) as $oFile)
        {
            if(
    false === $oFile->isDir())
            {
                
    array_push(
                    
    $aFiles,
                    array(
                        
    'directory'    =>    $oFile->getPath(),
                        
    'filename'    =>    $oFile->getFilename()
                    )
                );
            }
        }
        
    print_r($aFiles);
        
    /*
            Array
            (
                [0] => Array
                    (
                        [directory] => C:\path\to\directory
                        [filename] => foo.jpg
                    )
             )
        */
    }
    catch(
    Exception $oException)
    {
        echo 
    $oException->getMessage();
    }
    ?>
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  3. #3
    HAHA!
    Join Date
    Mar 2006
    Posts
    656
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thank you will try it out
    Cheap web hosting directory listing the cheapest web hosting

    Submit articles to an article directory


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
  •