Corey
Mar 6 2005, 08:42 AM
| | is there a php function that lists the content of some folder....
example:
/New folder
new.txt left.gif download.zip dc.exe
....so is there..?  |
Reply
Ao)K-General
Mar 6 2005, 12:44 PM
I have no clue. I think there might be but I dunno. There is something where you can register and the info goes to a folder. But I dunno.
Reply
yasir
Mar 6 2005, 01:49 PM
best thing would be to Google it! Try something like 'Advanced PHP Tutorials' Cheers! Yasir
Reply
HmmZ
Mar 6 2005, 02:14 PM
I don't think theres a pre-programmed function for that, you could, of course do it manually, updating it manually when your folder has new content: CODE <?php $folder_content = 'echo "The following files are content of the selected folder:" echo "$list"'; $list= "new.txt, left.gif, download.zip, dc.exe";
echo "$folder_content"; ?> You could put that in a new file called "folder_content.php" and then (for example in your indexpage, put the following line: include("folder_content.php"); That way you can easily edit the content it should display manually, while using minimum bytes for your indexpage. Hope that works for you (im just a newbie phper  )
Reply
bjrn
Mar 6 2005, 03:13 PM
QUOTE(Corey @ Mar 6 2005, 09:42 AM) is there a php function that lists the content of some folder.... There is opendir() which you can use to open a dir and then loop through the contents. CODE <?php if ($handle = opendir("yourdirhere")) { while (($file = readdir($handle)) !== false) { echo "filename: $file : filetype: " . filetype($dir . $file) . "\n"; } closedir($dh); } ?> Note that this will also list sub-directories and '.' and '..'. You can get info in the php.net documentation for opendir().
Reply
mobious
Mar 7 2005, 11:39 AM
i came up with this. it is similar with bjrn's but will sort all folder and files alphabetically. also will be conatined in a multi-dimensional array together with their name and statistics. CODE $directory = "path/to/dir";
while (($item = $directory->read()) !== false) { if ($item != "." && $item != "..") { $path = "{$directory->path}/{$item}"; if (is_dir($path)) { $tmp['name'] = $item; $tmp['stats'] = lstat($path); $dirs[$item] = $tmp; unset($tmp); } elseif (is_file($path)) { $tmp['name'] = $item; $tmp['stats'] = lstat($path); $tmp['extension'] = substr($item, strrpos($item, ".")); $files[] = $tmp; unset($tmp); } } }
ksort($dirs, SORT_STRING); sort($dirs);
ksort($files, SORT_STRING); sort($files);
Reply
iGuest
May 13 2008, 06:23 AM
Good Php Directory
Getting List Of Directories And Files Using Php
Here is a good PR4 Php directory Www.Businessservicesuk.Com -reply by Pete
Reply
Recent Queries:--
php list content of directories - 5.65 hr back. (1)
-
php list directories - 2.49 hr back. (3)
-
php display list of all folders in dir - 10.35 hr back. (1)
-
list directory in php - 12.43 hr back. (1)
-
php using readdir() to make a text file listing all files in a directory - 12.84 hr back. (1)
-
php list folders - 13.91 hr back. (1)
-
php get a list of directories - 14.27 hr back. (1)
-
go to all directories using php - 14.34 hr back. (1)
-
to get name of folders in a directory with php - 16.88 hr back. (1)
-
php list directory show only some files - 17.32 hr back. (2)
-
explode() in php list files and folders using php - 18.85 hr back. (1)
-
php how to list filename - 20.52 hr back. (1)
-
php create list of directories - 24.25 hr back. (1)
-
php create a list of directories - 25.41 hr back. (1)
Similar Topics
Keywords : list, directories, files, php, php, function, directory, file, list
- PHP Function To Add Previous and Next Page Feature
useful php function (0)
Php Configuration File
"config.php" (16) I did create this topic mainly because I want to know everything about that configuration file. I
will post other replies if I want to know more depending on your experience. Is this code correct
for that file: CODE <? $host="localhost"; $dbname="XXX";
$dbuser="XXX"; $dbpass="XXX";
$connection=mysql_connect($host, $dbuser, $dbpass) or
die(mysql_error()); mysql_select_db($dbname) or
die(mysql_error()); ?> Add your suggestions or i....
Need Some Help In File Browser
listing all sub folders and files in them. (8) Hey I want to create a very simple file browser, so that, it reads all the sub-folders which are
places in a directory, and the files inside the sub-folders (It reads only files inside sub-folders
and list them in simply. ) Also, it creates a directory (any name) inside each sub folder. My
Following code reads on the files inside the main directory, it does not read the files inside the
sub-folders.. I appreciate any help. CODE <? $path = "./"; $dir_handle =
@opendir($path) or die("Unable to open $path"); whil....
Endif function?
(6) As you get noticed before, I am studying PHP in examples like using the tutorials as well as books
itself. Through my readings, I get this function CODE <?php endif; ?> a lot of times.
So, what do you mean by this function, and what does it do exactly?....
Updating Php File Through A Web Form
(5) Hello, i'm not sure if this can be done with php or not but what i need is a way to make an php
file that have an html form on it and it will take the info you put in to that form and write it to
an existing php file, for example: if i have the file news.php and the file news_update.php. if you
went to news_update.php you would get an form with a text area for you to write a new addition for
the news.php file and when you hit submit it will add what you typed in the form to the file
news.php. If this is going to be a big code or a hard one to make but some one think....
Download Script For Mp3 Files
(0) Hello, I'm looking for a download script for sound files (e.g. mp3, avi, wma, and other ones).
i have found a few download scripts but they would not work for sound files for some reason. also
this will not be used for allowing downloading of illegal or riped music, what i will be using this
script for is i'm making a site for my church and the pastor wants to be able to recored the
services and then have me upload them to the site so that the church members can download them for
what ever reason. If some one could tell me how to make one or could show me a plac....
How To Display Images Of A Directory
(4) I am trying to do a simple thing. I want to display all the images of a directory on a single page
with the checkbox next to each image, so that i can select multi images and i can delete selected
images. Following few lines of code display the images of a directory.. i need help to put the
check boxes with each image. and I dont understand how can i select multi images with check box and
then delete them. I hope someone can help. thanks. CODE <?php $path = "./";
$dir_handle = @opendir($path) or die("Unable to open folde....
Php Ftp Upload Form
Adding User Directory to PHP Upload Form - Help (0) Alright I am trying to have a PHP FTP Upload Form that allows the user to create the directory
folder for where they want to upload there files to. example: Main Directory: vainsoft.com There
directory: vainsoft.com/modeling or vainsoft.com/photography But I dont want them to be able to
upload things into the main directory, only sub-directories, is that possible with this coding that
I have: //uses $_FILES global array //see manual for older PHP version info //This
function will be used to get the extension from the filename function get_extension($fi....
File Checker-how To Check File Whith Html Through Html?
(2) edit:sorry for the mistake it is php not html and its with not whith my code checking script= CODE
<?php $file = '$CHECK'; if (file_exists($file)) {
echo "The file $filename exists"; } else { echo "The file $filename
does not exist"; } ?> my question is how to check the file whith html example:on a page
a text box is provided and a button the user writes a file name (or website) the user clicks on the
submit button then it checks and show it (with the code above) i got the code C....
Arrays Outside A Function
Need to have arrays available to all functions. (3) I've got a bunch of arrays that i want to use for more then 1 function. when i declear the
arrays outside a function i cant use it in a function. This code was originally written in
javascript by another person but since I plan to use it and extend it with php I had to change it
from javascript to php code. In the javascript code the arrays were decleared outside the functions
with 'var arrayname' I read somewhere that declearing javascript variables with
'var' gives it global access. Any ideas on how I can go about declearing 1 set of these
arrays t....
Php And Flash Image Gallery
Need some help in creating or editing an xml file while viewing some o (5) Hello there and thanks for the helping hand you are offering. PHP newbie here! /ph34r.gif"
style="vertical-align:middle" emoid=":ph34r:" border="0" alt="ph34r.gif" /> So here is my problem:
On my website I have a flash image gallery.The way the gallery works is by uploading pictures in a
folder and editing? an xml file.(pics.xml) where it adds the following code when you upload a
picture: CODE <pictures> <image location="nameofpicture1.jpg"
desc="" /> <image location="nameofpicture2.jpg" desc="" /....
No File Extension
(3) On MediaWiki, the URL of the content is http://YOURWIKI.com/index.php/Blah Is it possible to
create a page or two that doesn't have a file extension? If so, how is it done?....
File Upload
File upload (1) I need to add a facility on my customer's website so his clients can send him jobs, typically
5mb - 50mb. I've looked around the web and researched this, and tried a few tests (failed), but
my brain's beginning to hurt. Could someone please tell me the best way to go about this,
please. The site is done in Flash, but I'm sure a link to an html page would be ok if necessary.....
How To Check If Fsockopen Function Is Enabled?
(2) Hi, I have VPS (virtual private server) and I have access to php.ini file. Is there any script that
will show that fsockopen function is enabled or where do I have to enable it? Searched google and
here and couldn't find anything. Thanks! ....
Grabt Access To My Protected Files
grabt access to my protected files (2) Hi all, I am sure all of you are great programers but First i am no code programmer i am just
trying to learn to run my sites, will the problem is i got a code from the web to protect my files
,1st i want to know how to work it out then i will try other things but can't let it go without
a fight thanx all php: CODE <?php if ( ! defined( 'myname' )
) { print "You cannot access this file directly."; exit(); }
customer data here ?> now i can't access my files what is the meth....
Security Issue Writing Files
Security issue writing files (1) Hi, first, sorry about my english. i am a beginner with php and i have some question about writing
files using php in a shared hosting. is a risk?, use database to store data is a better way? i just
want make an interface (in php) that write the data in a .html extension file to show to everybody
the html page and just the php interface is to the content manager. thanks in advance ....
<?php ?> Unique Visitors Script
Flat file unique visitors script (no sessions) (2) This is really simple script. Well at least this part is, but it could be extendable. Only problem
is that it's not really for massive websites with hundread of visitors a day, but rather for
small ones. But it is a good script to figure out how to make a visitor counter script. Anyway
here's the snippet. CODE <?php function getVisits($variable) {
$visits = array(); if ($handle =
opendir('stats/')) { while (false !== ($file =
readdir($handle))) { ....
Php Explode Function Help
(4) I am having trouble creating a script, all i want to achieve is to: 1. Select the variable from my
mysql database, which is in a format of : id|id|id|id| and so on... 2. Split them into separate
variables by using : $songexploded = explode("|",$ttyo ); 3. Then this is the bit I'm
stuck on trying to create a while loop from the $songexploded variables. So(this might not be
correct but you should get the idea).. CODE $x=1; while ($songexploded
==$result) echo $songexploded[$x].'<br>'; }....
Unofficial Trap17 Hosted Members Directory
(13) This is the Trap17 edition of the Hosted Members Directory. A script initially written by me for the
Astahost forums. The script has gone through many a changes and is currently in version 4 which
includes the following features:- > Listing of hosted members. > Listing of the websites of the
hosted members. > Validation of the websites (whether the site is suspended, working or not not
working, etc) > Save/Load result to/from database. > Multithreaded for faster operation. > Status
messages, images and progress bar to keep you informed of the process. Link to the Scrip....
The Best Zip Function
(1) hi my 6th code is very useful, you can zip your file by this: CODE <? class dZip{ var
$filename; var $overwrite; var $zipSignature =
"\x50\x4b\x03\x04"; // local file header signature var
$dirSignature = "\x50\x4b\x01\x02"; // central dir header signature
var $dirSignatureE= "\x50\x4b\x05\x06"; // end of central dir
signature var $files_count = 0; var $fh; Function
dZip($filename, $overwri....
Mail() Clone
A PHP mail() function clone (5) A lot of free web hosts have disabled the mail() function so you cannot send emails using PHP. Does
anybody know of a script that makes a function "like" mail but is able to be installed in a web
accessible directory and called included into another script and called like that? Or maybe you know
how to make such a function? I just really need to find a way around the free hosts turning of the
mail() function. I need to figure out a way to send emails.....
[php]simple Flat File Text Manipulator
Example on how to use forms to write to files in PHP (3) I made a simple flat file text editor, that can show you probably how simple it is to use forms with
php and write that data to file. This example has 2 files, submit.php, and postit.html. Submit.php
is used to write title, and some text, and add html tags, and paragraph tags where new paragraphs
are. Here's the file with comments. I think that HTML really doesn't need some more
explaining. CODE Title: <br /> <input type="text"
name="title" size="53"> <br /> Text: <br />
<textarea nam....
Edit .txt File In Ftp Via Webpage
file on external ftp (2) Right Im new here and stuggling with a problem im having. I've currently got a Login Script to
login to a external ftp and it displays the folders contents, however i need it so it echos a
specific file (coursedata.cfg) into a formarea which you can then edit the file and when u click
save it overwrites the file with the new one. Im really quiet getting annoyed with it xD as
everything i do ends up trying to include the file from the webserver the script is hosted on and
not the external ftp source. thanks Full Code Bellow Simple FTP Manager body { fon....
Reading Files From Directory To Array, And Using $_get To Get Them
Simple way to manage lot's of files (2) Some user posted a similar problem i had when i tried to figure out how to update content on my
website in less work as possible. This is just part of the "big" plan i have for my site but it can
be helpfull to you guys if you like FlatFile. I hope that mod's don't mind me posting the
same code here and on their forums, couse if they do i'll delete it from their forums
/biggrin.gif" style="vertical-align:middle" emoid=":D" border="0" alt="biggrin.gif" /> So
here's the situation. Let's say you have a folder called 'myfilesdirectory' on your
s....
Forms, Text Files, And Php For A Signature Generator.
Help a little. (1) Hello everyone! I am in need of some code a for a signature generator I am making. I am using
BuffaloHELP's code for the php file, now I am trying to improve that code by making a form in a
html file that will have the user say what is on the sig! But now, I need help getting the form
data that is posted by the user to get into that sig! There is a file, sig.txt, where that tells
the php file what text will go on the sig. But how can I make the form data in the html file go into
the text file so it will go onto the sig? You might want to read BuffaloHELP&....
How Good Is This Data Cleaning Function?
(2) Hi all, this is my first function and as part of a script and i just want to know a couple of
things. here is the code for the function: CODE <? function
clean($dirty_string) { $muddy_string = stripslashes($dirty_string);
$murky_string = strip_tags($muddy_string); $clean_string =
htmlentities($murky_string); }; ?> So the first thing is how secure is
it? the script this will be used in connects to a database and sends an email so it needs to stop
SQL injections and any email ab....
Include File.php?id=something
using the include() function (13) Well, I am making a full CMS system for my site, and want to make the index.php file to include the
view.php?id=1 file. I tried with this code, but it didn't work: CODE <?php include
'view.php?id=1' ?> This is the error I get: CODE Warning:
main(view.php?id=1) [function.main]: failed to open stream: Invalid argument
in C:\server\xampp\htdocs\test\index.php on line 1 Warning:
main() [function.include]: Failed opening 'view.php?id=1' for inclusion
(i....
How To Use A Link To Call Function In Php?
(8) The title says it all, really. How do you call a function using in PHP? I'm doing a project
and I stumbled upon this problem. I don't want to use query string in the href part like
since that would mess up the other part of my code. Can anyone pleae help me? I've pasted the
code below. /smile.gif' border='0' style='vertical-align:middle' alt='smile.gif' /> Thanksh.
CODE <?php function display($x){ //coding goes here. } ?>
<html> <body> <p align="center"> <a href="what g....
Script: Php Jukebox
A one file script! (4) This scripts is so simple, you dont need to edit ANY of it! All you have to do is make a folder
called 'songs' and put some audio files in it. Here is the whole page, I named it index.php
and put it in a folder called 'music': CODE <!DOCTYPE HTML PUBLIC
"-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd"> <html> <head>
<title>PHP jukebox</title> </head> <body> <!-- ©2005 Craig
lloyd. All rights reserved. Visit cragllo.com for more sc....
Change Permission With Php Code
code to change files' and folders' permissions? (3) As everyone know, there two ways (that I can think of) to change files' and directories'
permissions. One is to change it in your cPanel's Disk Manager and the other is with an FTP
client that supports chmod. Well, I'm doing something for my site that requires files to have
full permissions (Execute, Write, and Read on all three groups). At first, I thought that if I made
the directory 777, then every file created in that directory will be 777 as well. I'm wrong. An
alternative to doing this is to change each file permission myself, but that would be....
Looking for list, directories, files, php, php, function, directory, file, list
|
|
Searching Video's for list, directories, files, php, php, function, directory, file, list
|
advertisement
|
|