Jump to content

Search the Community

Showing results for tags 'scandir'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 5 results

  1. I am running php 5.4, IIS 7.5 on WinServer 2008 R2 box. I want to retrieve all subfolder names in a directory using PHP. I can successfully perform this task IF the target folder exists on the same drive as the php code, which is on c:\. However, I need to retrieve subfolder names from the e:\ drive on the same server. I have the permissions properly set for IUSR and IIS_IUSRS (read & exe, modify) for the target and parent folders but of course I don't have those permissions all the way to the root of e:\ drive. Using scandir(), I get "Access is denied. (code: 5)" but I have tried glob() and RecursiveDirectoryIterator to no avail. I have not been able to find a solution or an example so perhaps it is not possible. Any recommendations are greatly appreciated.
  2. Hey guys, i have created a php file which takes two parameters: a subdirectory path a file extension it then echos the complete path pf (glob()) all the files with that extension in the searching folder. I wanted to know the security issues involved with this and how i might use escape methods to make sure someone can't move up the directory listing and get other filename. Are there any other concerns i should have? No data is coming or going to a database however there are other php files on the server which communicate with mySQL. Thanks alot!
  3. Hi Freaks I created a Joomla 1.5 install.xml using scandir. For easier orientation, folders are capitalized and blue ASSETS - index.html - CSS - - index.html - - popup.css - - default.css - JS - - index.html - - form.js CONTROLLERS MODELS TABLES VIEWS controller.php index.php reporter.php output of the first 14 lines: <filename>ASSETS</filename> <filename>ASSETS/CSS</filename> <filename>ASSETS/CSS/default.css</filename> <filename>ASSETS/CSS/incident_reporter_form.css</filename> <filename>ASSETS/CSS/index.html</filename> <filename>ASSETS/CSS/popup.css</filename> </filename> <filename>ASSETS/index.html</filename> <filename>ASSETS/JS</filename> <filename>ASSETS/JS/incident_reporter_form.js</filename> <filename>ASSETS/JS/index.html</filename> </filename> </filename> <filename>controller.php</filename> <filename>CONTROLLERS</filename> My script $allfiles = ''; function readFolders($dir ) { global $allfiles; $files = scandir($dir); foreach($files as $f) { if($f != '.' && $f != '..') { $allfiles .= '<filename>'.$dir.'/'.$f; if(is_dir($dir.'/'.$f)) { $allfiles .= "</filename>\n"; readFolders($dir.'/'.$f); } $allfiles .= "</filename>\n"; } } $fp = fopen('xml_scandir.txt', 'w') or die('cannot open file'); fwrite($fp, $allfiles); fclose($fp); } readFolders('com_reporter'); Question: Why do I have those extra closing tags </filename> that attach outside if(is_dir) ? I would understand if the output came with empty tags, eg <filename></filename> Thank you Fero
  4. I'm trying to scan a directory and return a single specific folder,( the last one created) This is for a photo website and I would like to use images from current weeks images for the header images without having to upload them to a rotator folder. So here's where I'm at $dir = './This/2013/Goes to specific class of race/'; $files1 = scandir($dir); rsort($files1); print_r($files1); Returns all files in DESC order, including a photo.xml file generated by album builder, Array ( [0] => photos.xml [1] => 09_01_2012 [2] => 08_25_2012 [3] => 08_18_2012....ect,ect I want it to always ONLY return the NEWEST album folder, which in this example its ([1] => 09_01_2012) That's why I resorted into descending figuring the newest would always be on top of list. But I can not figure out how to JUST GET that single folder. ____________________________________________________________ Then I need to access that NEWEST folder and randomly select a .jpg file form it. If I manually insert the correct path I can get it to select a random file using this [/size][/font][/color] <?php //path to directory to scan $directory = "a/2013/direct/path/"; //get all files in specified directory $files = glob($directory . "*"); //print each file name foreach($files as $file) echo $file; } } ?> Above code with below code returns a random .jpg file, i CAN NOT GET THEM TO WORK COMBINED [color=#000000][font='Times New Roman'][size=1] [/size][/font][/color]/<?php // retrieve one of the options at random from the array $file = $files[rand(0,count($files))]; print_r($file); ?> I know very little about PHP, have done some CF coding but either way I hack my way through.... Any help or suggestions would be greatly appreciated, If you get me leaning the right direction, I can usually figure out the logic and complete it.... Hope I made sense to someone! LOL Steve
  5. Hi guys I needed some help and I found this forum so I thought I'd give it a try. I have this lab that Im doing and instructor really didnt go into detail on how to do it even the code that was demoed was not really helpful in the class . My issue is that I cant seem to get my foreach loop to read the files in the directory i specified and display the name along with being able to play the file as well . Any pointers would be great its over my head at this point . Thanks <!DOCTYPE html > <head> <title>Music Viewer</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <link href="http://www.cs.washington.edu/education/courses/cse190m/09sp/labs/3-music/viewer.css" type="text/css" rel="stylesheet" /> </head> <body> <div id="header"> <h1>190M Music Playlist Viewer</h1> <h2>Search Through Your Playlists and Music</h2> </div> <div id="listarea"> <ul id="musiclist"> <!-- *means is equivalent to windows explorer search --> <?php foreach (scandir(C:\Users\test\Desktop\Main\xampp\htdocs\mp3)("./mp3/*.mp3") as $song) { ?> <li class="mp3item"> <a href="./<?= $song ?>"> <?= basename($song) ?> </a> <!--end of href -- > </li> </ul> </div> </body> </html>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.