How To Access A Folder In Php Page

free web hosting
Free Web Hosting, No Ads > CONTRIBUTE > Computers > Programming Languages > PHP Programming

How To Access A Folder In Php Page

itssami
I have a folder on my hosting space..(i.e. public_html), i want to add this folder on my php page.., . how it should be done that, when i add some file in the folder using ftp or anything , the folder on that page automatically includes that file.for example , if the folder has 5 files..and on page it says "folder has 5 files"
and shows the files...and when i have uploaded 2 more files ,it should automatically say that folder has 7 files..

Reply

jlhaslip
Look at the php.net site for the functions relating to directories such as isdir(), readdir().
Simply read the contents of the directory while looping and count the number of files, then echo or print the results. Exclude the sub-directories while looping.
That is a rough outline of the the pseudo-code to perform the task. I think I have a script which might need some changes to it in order to do exactly what you want. Do you code in php? If so, PM me and I'll see if I can find it to send to you.

CODE
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>
<title>An XHTML 1.0 Strict Page to List the files in this directory</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
</head>

<body>

<p>... Your HTML content here ...</p>
<?php
//dir_list.php
$default_dir = "./"; // lists files only for the directory which this script is run from
echo '<div id="link_div"><ul>' . "\r\n\t";
if(!($dp = opendir($default_dir))) die("Cannot open $default_dir.");
while($file = readdir($dp)) {
if(is_dir($file)) {
continue;
}

else if($file != '.' && $file != '..') {
echo '<li><a href="' . $file . ' " class="link_li" >' . $file . '</a></li>' . "\r\n\t";
}
}
closedir($dp);
echo '</ul> </div>';

?>

<p>... Your HTML content here ...</p>

<p>
<a href="http://validator.w3.org/check?uri=referer">validate the xhtml</a>
</p>
</body>
</html>



This script lists the files as links. You will have to Mod it to count the files and echo the results of the count. And add the CSS styling for the UL and LI's , etcetera. Not a biggie.

 

 

 


Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Recent Queries:-
  1. get all images in folder php - 22.14 hr back. (1)
  2. accessing folders php - 26.41 hr back. (1)
  3. php list contents in folder - 27.51 hr back. (1)
  4. php login script to access protected folder - 34.83 hr back. (1)
  5. php access a folder - 44.19 hr back. (1)
  6. php codes link for folder - 57.28 hr back. (1)
  7. deleting a image from folder inphp - 60.73 hr back. (1)
  8. php class files in different folders - 73.28 hr back. (1)
  9. accessing folder using php - 77.41 hr back. (1)
  10. count number of files in a folder php - 92.45 hr back. (1)
  11. php include back folder - 95.98 hr back. (1)
  12. how to add a link to file folder from web page - 96.42 hr back. (1)
  13. php.net create page and folder - 98.37 hr back. (1)
  14. php code for delete files from a folder - 102.68 hr back. (1)
Similar Topics

Keywords : access, folder, php, page

  1. Ms-access Database Question
    Allowing Web Access to the Informaton (3)
  2. 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....
  3. How To Delete Uploaded Picture From A Folder
    (1)
    i wrote some code to upload the pictures to a folder and after it has uploaded, there's a page,
    say pics.php.. it displays all pictures of the folder to that page. now i want to add an option to
    delete the pictures. for example i want to add a link "Delete" under every pic, that when i click it
    deletes the pic from the folder and deletes the pic data from mysql. How i can delete the pic from
    the folder? thanks ....
  4. I Need Webmail On My Server
    (so admins on my site can access it) (0)
    Right now, if i go to the cpanel of my site, I can access webmail of any of the email addresses I
    have. Unfortunatly, I would prefer it if the administrators did not know the password to the
    cpanel. I want them to be able to access mail from 1 of the email accounts. I have tried letting
    all the admins access the account through their own cliants, but it became a mess, not knowing wich
    admins have responded to which emails, because most emails are hosted localy when received by
    cliants such as outlook. Then I had the idea of making one page, with webmail on it. Where....
  5. Restricting Page Access Using Php (need Help)
    (10)
    The code below is suppose to restrict access to pages without proper username and password.
    I've copied it word for word from a book I bought and I've tested it offline. I've
    already entered appropriate values in the database and nothing is wrong when I query. The problem
    is when I enter a wrong combination of username and password nothing happens when it should go back
    to index.html. Also when I correctly entered the username and password secretpage.php doesn't
    display anything. I'm guessing it has do with the setcookie function in login.php or ....
  6. Php Classes
    Access the same class instance over multiple pages (1)
    Hey everyone. I am having some trouble accessing the same php class instance in more that one page.
    This is for my login script and what i need to do is be able to call the classes logout function
    from a separate page. What i have tried to do is create a new .php page and include the class file
    and then make a new class and call logout. This does not work because it does not log out the
    current user which is my problem. Can anyone help me fix this or know of another way to do it?
    Below is my class file CODE <?php     // member class     // handlers member logo....

    1. Looking for access, folder, php, page

*RANDOM STUFF*





*SIMILAR VIDEOS*
Searching Video's for access, folder, php, page

*MORE FROM TRAP17.COM*
advertisement



How To Access A Folder In Php Page



 

 

 

 

ADD REPLY / Got an Opinion! a humble request :-) RAPID SEARCH! Free Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE