?
Solved

php count the file is folder

Posted on 2013-02-01
3
Medium Priority
?
346 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 17

Expert Comment

by:Chris Harte
ID: 38844021
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
ID: 38844048
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 17

Accepted Solution

by:
Chris Harte earned 2000 total points
ID: 38844089
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

WordPress Tutorial 4: Recommended Plugins

Now that you have WordPress installed, understand the interface, and know how to install new parts, let’s take a look at our recommended plugins.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

These days socially coordinated efforts have turned into a critical requirement for enterprises.
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
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 create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

777 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