note 102468 rejected from function.opendir by danbrown

[email protected] Wed, 16 Feb 2011 09:09:51 -0800
Newsgroups php.notes
Message-ID <[email protected]>
Note Submitter: Allenc at rdsinvestments dot com dot com 

----

I have a script that will ope a directory and list its contents with a link. If I am using it to call up mainly word docs and docx is there a way to have the browser render the links rather than offer a download????

<?php 
            $uploads = wp_upload_dir();
 
                        if ($dir = opendir($uploads['basedir'].'/releases')) {
                                    $releases = array();
                           while (false !== ($file = readdir($dir))) {
                        if ($file != "." && $file != "..") {
                                    $releases[] = $file; 
                        }
            }
                        closedir($dir);
}
 
 
echo '<ul>';
foreach($releases as $releases) {
            echo '<li><a href="';
            echo $uploads['baseurl'].'/releases/'.$releases;
            echo '" title="' . $releases . '">';
            echo $releases;
            echo '</a></li>';
}
echo '</ul>';
?>