scandir

Sending Variables for PHP FileSystem Functions with Form Submission

I'm trying to find a secure way to do the following: Users enters value into html form. Form is submitted. PHP uses submitted value as the argument for the "scandir" function. My theory is include logic in the php script that forbids absolute paths and requires the directory name to include a certain value. My concern is that a hack...

How do you get a directory listing sorted by creation date in PHP?

Hi, I have to list directories by using scandir() function but result array should be sorted according to date and time of directory created. Regards Deepak ...

PHP scandir strange behaviour

ok, so what i'm trying to do is to scan the "previous" folder. $scanned = scandir(".."); foreach($scanned as $file){ if(is_file($file)){ print $file."<br />"; } } even though in my ".." directory i have 20+ files i get just three rows index.jpg index.php template.dtd i noticed that if i don;t use that is_file if clause it re...

output files from a second directory in same php function

I have the following code to output images from directory im/, how can I tweak this to also output images from another diectory called out/ (for example)? As to echo another img tag under the current one? <?php $imgDir = "im/"; $images = scandir($imgDir); $ignore = array( ".", ".." ); natsort($images); foreac...

Encoding problem with preg_replace() and scandir()

Hi, On OS-X (PHP5.2.11) I have a file: siësta.doc (and thousand other with Unicode filenames) and I want to convert the file names to a web-consumable format (a-zA-Z0-9.). If I hardcode the file name above I can do the right conversion: <?php $file = 'siësta.doc'; echo preg_replace("/[^a-zA-Z0-9.]/u", '_', $file); // Output: si_s...

PHP (images folder) image Listing in Alphabetical Order?

Hello, I'm having problems with a PHP script trying to list images alphabetically. I need this urgently and I have not much knowledge of PHP. I was trying to use scandir() but I'm not succeeding. Thanks for your help!! Here is the code: function listerImages($repertoire){ $i = 0; $repertoireCourant = opendir('./'.$repertoire); whi...

use php scandir($dir) and get only images!

Is there any way to get only images (jpeg,png&gif) while using: $dir = '/tmp'; $files1 = scandir($dir); ...

PHP: readdir to scandir?

i wonder how i can transform exactly the following piece of code to scandir instead of readdir? $path = 'files'; //shuffle files $count = 0; if ($handle = opendir($path)) { $retval = array(); while (false !== ($file = readdir($handle))) { $ext = pathinfo($file, PATHINFO_EXTENSION); if ($file != '.' && $file != '...

using PHP.scandir() to scan files and then require_once them

hi again every one this is my third question so far on stackoverflow :D i am defining files and their location on my first_run.php files, the files that i define here is those files containing classes, helper functions and any other files required at early development, this first_run.php contains only a few lines of codes but the line ...

Scandir Never Returns

Hi, I am developing using a Windows 7 machine with the local server being UniServer. I have some PHP code to include all php files in a directory. # Include all library classes. $library_files = scandir(LIBRARY_PATH); foreach ($library_files as $file) { $path_parts = pathinfo($file); if ($path_parts['extension'] == 'php') { ...