scandir

glob() to build array of files, or hardcode array? Speed is key, but automation is nice

送分小仙女□ 提交于 2019-12-25 14:23:31
问题 Sorry for the undescriptive title, wasn't to sure what to title this :-) I have written an API that loads required javascript libraries from a directory on my server. The directories have a specific format, the only thing that can differ is the file name format within each libraries' directory. The Directory Format _js/_source/_library_name_here/file_name_here.js e.g. /_js/_source/_fancybox/jQuery.lightbox-0.5.js The array (currently hardcoded) At the moment I have the separate libraries

glob() to build array of files, or hardcode array? Speed is key, but automation is nice

允我心安 提交于 2019-12-25 14:23:13
问题 Sorry for the undescriptive title, wasn't to sure what to title this :-) I have written an API that loads required javascript libraries from a directory on my server. The directories have a specific format, the only thing that can differ is the file name format within each libraries' directory. The Directory Format _js/_source/_library_name_here/file_name_here.js e.g. /_js/_source/_fancybox/jQuery.lightbox-0.5.js The array (currently hardcoded) At the moment I have the separate libraries

PHP Using Scandir with and External URL - Not Implemented

微笑、不失礼 提交于 2019-12-25 10:57:26
问题 I'm having some trouble using scandir - I have it working fine on one site but now I'm wanting to scan the same directory on that site but from a different website. I'm using the following code: array_diff(scandir('http://sub.domain.co.uk/folder/folder/'), array('.', '..')); and I get this error: Warning: scandir(http://sub.domain.co.uk/folder/folder/): failed to open dir: not implemented I've had a Google but brought up very little - I've tried enabling directory listing on the external site

scandir issue with accents in Linux work fine in OSX

夙愿已清 提交于 2019-12-25 06:32:28
问题 Hi im using the next function to create a tree directory menu in my website, the directories include a lot of pdf and excel, sometimes the name of this files have accents, spaces and ñ, My application work perfectly in OSX (mac) but a soon I uploaded in my godaddy server (linux), all the characters with accent were replace by the ? character breaking all the names and the link. Do you know how to deal with this issue? I been reading about urlencode, urlrawencode, inclusive I read, this

php scandir() not showing files - only showing directories

那年仲夏 提交于 2019-12-23 21:42:40
问题 I have a directory structure as follows: /files /files/001 /files/001/addfile.php /files/002 /files/002/deletefile.php /files/003 /files/003/viewfile.php My script: error_reporting(E_ALL); $directory = 'files'; $files = scandir($directory); $xml = new DOMDocument('1.0', 'UTF-8'); $xmlFiles = $xml->appendChild($xml->createElement('FILES')); if(is_dir($directory)) { print_r($files); } /*foreach($files as $file => $key) { if($file == '.' || $file == '..') { continue; } echo '$file: '.$file; if

look for a specific filetype in a directory in php and send it to a different directory after conversion

末鹿安然 提交于 2019-12-23 19:17:06
问题 I have a directory in which there is a mp4 file (including other files as well) which I want to convert into mp3 and then send it to different directory. I have used the following command line command to covert into mp3 and its working perfectly fine. ffmpeg -i 36031P.mp4 -map 0:2 -ac 1 floor_english.mp3 mp4 file is inside in_folder . Using ffmpeg, I want to convert mp4 file into mp3 and send it to out_folder . <?php $dir = 'in_folder'; $files1 = scandir($dir); print_r($files1); /* It lists

Reading *.csv files from directory and showing the content of each file fails

£可爱£侵袭症+ 提交于 2019-12-23 09:15:34
问题 I need help with reading the folder and opening / outputting the csv data, I have used examples other people have written but none of them have worked for me. What I currently have is this, but it doesn't output the files: $files = scandir($PathToCreate.$version."/"); //scan the folder foreach($files as $file) { //for each file in the folder //The following is another example I found but does not output anything I just need to open each file and be able to output / target specific data $csv =

with os.scandir() raises AttributeError: __exit__

和自甴很熟 提交于 2019-12-23 07:11:13
问题 An AttributeError is raised when I use the example code from python's documentation (here). The example code is as follows: with os.scandir(path) as it: for entry in it: if not entry.name.startswith('.') and entry.is_file(): print(entry.name) The result is an AttributeError : D:\Programming>test.py Traceback (most recent call last): File "D:\Programming\test.py", line 3, in <module> with os.scandir() as it: AttributeError: __exit__ Although, assigning os.scandir() to a variable works fine.

PHP Scandir returns extra periods

守給你的承諾、 提交于 2019-12-19 10:12:00
问题 So I am trying to build a script that scans a directory and returns random images to be used as backgrounds. The php looks like this: $dir = "views/img/bg/"; $dh = opendir($dir); while (false !== ($filename = readdir($dh))) { $files[] = $filename; } $random_key = array_rand($files, 1); $random = $files[$random_key]; Then I am just using some simple jquery to attach the images as backgrounds: <script> $(document).ready(function(){ $("body").css( "background" , "url(http://'.$url_root.'/views

PHP scandir of an url

有些话、适合烂在心里 提交于 2019-12-18 07:23: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 . '/'