Solved

php count the file is folder

Posted on 2013-02-01
3
322 Views
Last Modified: 2013-03-05
I have this code works fine if i leave the directory the blank will count the the number if files
<?php

$directory = ' ';
$images = glob($directory . "*.txt");


$filecount = count(glob($directory . "*.txt"));
echo "<p><b>";
echo $filecount;


?>

Open in new window

but  when I want to do this it does not work
<?php

$directory = 'C:\Projects\test';
$images = glob($directory . "*.txt");


$filecount = count(glob($directory . "*.txt"));
echo "<p><b>";
echo $filecount;


?>

Open in new window

also would need some code to allow across a network eg \\\192.168.0.1\folder
0
Comment
Question by:beridius
  • 2
3 Comments
 
LVL 16

Expert Comment

by:Chris Harte
Comment Utility
The php server does not have access to the c:\ drive.  When left blank it will default to the root of the server, this is where the server is located on your hard drive, not the root of the hard drive.
0
 
LVL 2

Author Comment

by:beridius
Comment Utility
so would I have to use ../../ to located my folder that I need ?

 but even i just put /test it does not work?
0
 
LVL 16

Accepted Solution

by:
Chris Harte earned 500 total points
Comment Utility
Depends where the folder is. The default installation directory in windows is

C:\Program Files\Apache Software Foundation\Apache2.2

in linux it is

/var/www/html/

To the php server, this is the root, it cannot go above this. All the directories you want to work with have to be in this root directory.
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now