How to use PHP readdir to read files in directories outside of the root level and link? -
I have a php (side navigation menu- where php script) that stays at the root level of my webserver.
I want to use a php readdir or scandir for a list of contents of a separate folder (/ report_1) on a server with links to those files except HTML, HTM and XSLT extensions. Or just to include the php extension)
Currently I am using a reader which reads the content of the current directory that resides in it and returns the link except for some file types Land. (See code below)
I would like to include the "php" file at the end, which contains the lists and links to files outside the "included" root level. Any help would be greatly appreciated.
& lt ?? Php // These files will be ignored $ Excluded Files = Array ('excludeMe.file', 'excludeMeAs.well'); // These file extensions will be ignored for $ Excluded Extents = Array ('html', 'htm', 'php'); // Make sure we ignore and .. $ Excluded Files = array_merge ($ Excluded Files, Arrays ('.', '..')); // Convert short case so we ($ i = 0; isset ($ Excluded Files [$ i]); $ i ++ $ $ Excluded Files [$ i] = Stroller ($ ltrim ($ i $) ($ I = 0; isset ($ Excluded Extension [$ i]); $ i ++) $ Excluded Extension [$ i] = Stroller ($ Excluded) for '.' If $ ($ handle = opendir ('.')) {While (false! == ($ file = readdir ($ handle))} through the extension [$ i] $ Extn = explosion ('.', $ File); $ Extn = array_pop ($ extn); // Link only for those files If you do not match our rules (!! In_Are (stroller ($ file), $ Excluded files) & amp;; in_array (Stormware ($ extn), $ Excluded Extensions) {$ count ++; Print (" Lt; a href = \ ". $ File." \ "& Gt; $ file". & Lt; / a & gt; & lt; br / & gt; \ n ");}} echo & lt; br />
- Make a directory loop a function.
- If the current file is a directory using is_dir, check it
- If so, then run that directory again through the same function.
- otherwise print as a filename.
You may want to consider using the full path in your link.
Hope this will be helpful.
Comments
Post a Comment