scandir

Does php scandir() exclude hidden files under Windows?

北城余情 提交于 2019-12-10 23:42:16
问题 On a Windows system, a backup agent created temporary hidden files of nearly the same name as the original files, and in the same path. This was probably disturbing a process that used PHP scandir() . Now I was wondering if files on Windows having the hidden flag set are excluded by PHP scandir() . There are some articles about the hidden files in Linux style, how scandir() should ignore files that start with a dot, but there is rarely no info about Windows files. 回答1: I have tried this code

How to access a remote directory and copy files in PHP

筅森魡賤 提交于 2019-12-10 18:38:13
问题 I want to copy files from a remote directory. But I don't know how to write its UNC. I can use file://Server/Production/Images to open the directory in a browser, but it can't work if I just use this path in my PHP script. $origin = "file://Sever/Prodution/Images"; $file = scandir($origin); The rusult is : Warning: scandir(): remote host file access not supported I have run my wampsever as an administrator, so I assume it can access to remote sever. 回答1: Without doing any research, I am not

how can I parameterize select function in scandir

。_饼干妹妹 提交于 2019-12-10 17:09:28
问题 The scandir() function scans the directory dir, calling select() on each directory entry as "int(*filter)(const struct dirent *)" How can I pass pattern value as parameter to fnmatch(const char *pattern, const char *string, int flags) function used in filter ? Here my sample code int my_selectgrf(const struct dirent *namelist) { int r = 0; char my_pattern[] = "*.grf"; r = fnmatch(my_pattern, namelist->d_name, FNM_PERIOD); return (r==0)?1:0; } scandir("/pub/data/grf", &namelist, my_selectgrf,

scandir - sort numeric filenames

倖福魔咒の 提交于 2019-12-08 19:39:53
问题 Done some searching, but can't seem to find the exact answer I'm looking for. I'd like to pull in files with numbered filenames using 'scandir($dir)', but have them sort properly. For example, file names are: 1-something.ext 2-something-else.ext 3-a-third-name.ext . . . 10-another-thing.ext 11-more-names.ext The problem I'm having is that 10-a-fourth-thing.ext will show before 2-something-else.ext. I'd like to find a better way of solving this issue than introducing leading '0' in front of

PHP: Using scandir(), folders are treated as files

十年热恋 提交于 2019-12-07 10:26:51
问题 Using PHP 5.3.3 (stable) on Linux CentOS 5.5. Here's my folder structure: www/myFolder/ www/myFolder/testFolder/ www/myFolder/testFile.txt Using scandir() against the "myFolder" folder I get the following results: . .. testFolder testFile.txt I'm trying to filter out the folders from the results and only return files: $scan = scandir('myFolder'); foreach($scan as $file) { if (!is_dir($file)) { echo $file.'\n'; } } The expected results are: testFile.txt However I'm actually seeing: testFile

How to set and use PHP_INI_SCAN_DIR environment variable in PHP? [duplicate]

自作多情 提交于 2019-12-04 17:28:47
This question already has answers here : Is it mandatory to configure PHP in order to scan configuration INI files on a per-directory basis(i.e. .htaccess files in my case) by PHP? (1 answer) How do I include a php.ini file in another php.ini file? (7 answers) how to set environment variables in apache xampp ? (1 answer) Closed last year . I've installed PHP 7.2.3 on my machine running on Windows 10 . I've installed PHP and Apache httpd 4.29 using latest copy of XAMPP package . I come across following text from the PHP Manual It is possible to configure PHP to scan for .ini files in a

Sending Variables for PHP FileSystem Functions with Form Submission

北慕城南 提交于 2019-12-04 04:20:58
问题 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 hacker could use my form to submit his own value and access sensitive files. This is for a JQuery plugin. I don't want users to have to modify the PHP file. How could

How to properly use scandir() in c?

天大地大妈咪最大 提交于 2019-12-03 09:31:51
I am trying to store list of files in a char** variable. scandir() finishes properly but I get a segmentation fault when trying to print the char**. Here's the code: int main() { char** fileList; int noOfFiles; char* path = "."; makeList(&fileList, &noOfFiles, path); return 0; } void makeList(char ***fileList, int* noOfFiles, char* path){ struct dirent **fileListTemp; *noOfFiles = scandir(path, &fileListTemp, NULL, alphasort); int i; fileList = (char***)malloc(sizeof(char***)); *fileList = (char**)malloc(*noOfFiles * sizeof(char*)); printf("total: %d files\n",*noOfFiles); for(i = 0; i <

Sending Variables for PHP FileSystem Functions with Form Submission

拥有回忆 提交于 2019-12-01 21:19:34
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 hacker could use my form to submit his own value and access sensitive files. This is for a JQuery plugin. I don't want users to have to modify the PHP file. How could the below code be hacked? <?php $foo = $_POST["some_directory"]; //validate $foo //make sure path to

PHP scandir of an url

天大地大妈咪最大 提交于 2019-11-29 12:56:16
How can I use scandir with an URL. Now it looks like PHP doesn't see the URL as an URL. Is there a way to use an URL in scandir? <form action="new_exercise.php?id=<?php echo $new_id; ?>" method="post"> <input class="" type="text" name="name_exe" required placeholder="Project naam"> <select name="audio" required> <option></option> <?php $path = 'URL comes here'; $results = scandir($path); foreach ($results as $result) { if ($result === '.' or $result === '..') continue; if (is_dir($path . '/' . $result)) { echo "<option>" . $result . "</option>"; } } ?> <select> <input class="btn-success" type=