473,698 Members | 2,751 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

php folder files retrieve

Jacotheron
44 New Member
Hi all
I need a php script that can access a folder on the server to list all the files in the folder. While trying to get a solution, I found this script that can list folders in the wamp index.php-file:
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $projectsListIgnore = array ('.','..');
  3. $handle=opendir(".");
  4. $projectContents = '';
  5. while ($file = readdir($handle)) 
  6. {
  7.     if (is_dir($file) && !in_array($file,$projectsListIgnore)) 
  8.     {        
  9.         $projectContents .= '<li><a href="'.$file.'">'.$file.'</a></li>';
  10.     }
  11. }
  12. closedir($handle);
  13. if (!isset($projectContents))
  14.     $projectContents = $langues[$langue]['txtNoProjet'];
  15. ?>
it should also link towards the files that get listed

Can someone please help me

Merry Christmas to all
Dec 29 '08 #1
1 2282
djpaul
137 New Member
Hey Jacotheron.
Sure it's possible!
Expand|Select|Wrap|Line Numbers
  1.  <?php
  2.  $handle=opendir(".");
  3.  
  4.       while ($file = readdir($handle)) {
  5.  
  6.           if ((is_dir($file) && (substr ($file, 0, 1) != '.' )){        
  7.  
  8.               $projectContents = '<li><a href="' . $file . '">' . $file . '</a></li>';
  9.  
  10.           }//end if
  11.  
  12.      }//end while
  13.  
  14.    closedir($handle);
  15.  
  16.    if (!isset($projectContents))
  17.        $projectContents = $langues[$langue]['txtNoProjet'];
  18. ?>
  19.  
Maybe this will work, try it or download the php manual.
There are many tutorials in it!

greetz paul
Dec 30 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

7
2340
by: BB | last post by:
Hi, How do you retrieve the names of all files in a folder. I am trying to execute a piece of code on all files in a folder supplied to the program in the argument list. What are the c++ commands for folder and file manipulations Thanks
5
16777
by: Rosa | last post by:
Hi, I'm trying to clear the TIF on Windows XP programmatically with the below code. This code works fine on any folder but the TIF. For some reason the atEnd() statements always defaults to true and no files are deleted in the folder. The peculiarity of this issue is that the files/subfolders cannot be seen through the windows explorer either. I can only access/delete them through a command shell. Any ideas?
1
2608
by: Wayne | last post by:
I'm using the following code from the Access Web to open a folder. The folder opens in "List" View. Is there an addition that I can make to the code to force the folder to open in "Details" view? 'This code was originally written by Ken Getz. 'It is not to be altered or distributed, 'except as part of an application. 'You are free to use it in any application, 'provided the copyright notice is left unchanged. '
2
11056
by: musicloverlch | last post by:
I need to import 60 text files all in one folder. Can I use VBA to cycle through all the files, without having to import them one by one? Does anyone have an example? Thanks in advance. Laura
2
1725
by: John | last post by:
Hi all, I haven't a clue where to begin here (or more to the point - if it's even possible). I need to read the names of all the files inside a folder off my web site. The catch here is that I don't know the absolute path here (C:\inetpub\whatever\whatever\etc...) as it could be on any drive at my ISP. Is there a way to retrieve a list of these files by somehow using the
2
5042
by: John Regan | last post by:
Hello All I am trying to find the owner of a file or folder on our network (Windows 2000 Server) using VB.Net and/or API. so I can search for Folders that don't follow our company's specified folder structure and naming conventions and then send a Net send message to those users telling them to rectify. The information I want to get is when you select the file/folder and then: Properties -> Security Tab -> Advanced Button -> Owner Tab ->...
1
1353
by: SqlBeginner | last post by:
I have a physical folder which contains 'n' number of documents (*.docs), excel sheets (*.xls), few PDF files (*.pdf). These files contains images within these files. Now from my website (ASP.NET 1.1, C#) I want to search through these files. That said, I was able to think of the below two options for solving this: 1. Microsoft Index Server :: Create a catalog and map the physical folder here. Then make use of FreeText queries to fetch...
8
8925
by: mdh2972 | last post by:
I would like to put all my .jpg images in a folder into an array to be viewed. can I use JS to do this automatically. Without having to type by hand?
1
1378
by: stuck1512 | last post by:
hi, i was writing an apache module & successful in retrieving archived files from a folder. i compared all file properties before retrieving but the problem is now i have to retrieve them as per dats i.e from () date to () date they wr archived on!! i have already done it with comparing its archived date only but nt able to get number of files from one date to another date( more thn one file at a time). hope you got my doubt. can u plz...
6
3157
by: kimiraikkonen | last post by:
Hello, I have a listbox and folder browser control. I need to display all .mp3 files' pathes into listbox. It was Ok with openfiledialog but how can list all .mp3 extension- having files into my listbox using folder browser control. A sample code would be great.
0
8603
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9157
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8861
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7723
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5860
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3045
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2328
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2001
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.