/    Sign up×
Community /Pin to ProfileBookmark

Read files from a folder

Hello guys, I was wondering if anyone could tell me how to read files from a folder (in php) and show them to the user.
And if it’s possible, to show them in a table
Thx in advance ??

to post a comment
PHP

5 Comments(s)

Copy linkTweet thisAlerts:
@ShrineDesignsJan 30.2005 — example[code=php]<?php
$path = 'path/to/';

if(($dh = opendir($path)) !== false)
{
while(($file = readdir($dh)) !== false)
{
if($file != '.' && $file != '..')
{
$fp = fopen($file, 'rb');
$contents = fread($fp, filesize($file));
echo '<pre>' . htmlspecialchars($contents) . '</pre>';
fclose($fp);
}
}
closedir($dh);
}
?>[/code]
Copy linkTweet thisAlerts:
@Gert-JanauthorJan 30.2005 — I'm getting this error

Warning: opendir(http://www.cwkinc.us/gert-jan/torrent/): failed to open dir: not implemented in /home/wiz/public_html/gert-jan/show.php on line 4

I used the exact code of you, but changed the path to http://www.cwkinc.us/gert-jan/torrent/

I also tried to chhmod but didn't work.

Anyone knows what the problem is.
Copy linkTweet thisAlerts:
@ShrineDesignsJan 30.2005 — is the directory on the same server as the script?

if not it will not work
Copy linkTweet thisAlerts:
@Gert-JanauthorJan 30.2005 — Yes, it's on the same server
Copy linkTweet thisAlerts:
@jajtiiiJan 30.2005 — Try

/home/wiz/public_html/gert-jan/torrent/

instead of

http://www.cwkinc.us/gert-jan/torrent/
×

Success!

Help @Gert-Jan spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...