473,811 Members | 3,640 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

problem checking of a file is a file or a directory

sanjay123456
125 New Member
Dear friends ,

I am using window os . i face a problem is that

[PHP]

$file="D:\Domai ns\\naturetrail sindia.info\www root\html\\";
$file=$path."\h tml\\";
$d = dir($file);

while (false !== ($entry = $d->read())) {
$typ = filetype($entry );
if($typ == "dir"){
print '<li>[d]:'.$entry.'</li>';
}else if($typ == "file"){
$topic=explode( ".",$entry) ;
// $tname=$topic." .html";
if($topic[0] <> "") {
print '<li><input type="checkbox" name="check[]" value="'.$topic[0].'"><a href="edit.php? f='.$topic[0].'">'.$topic[0].'</a></li>';
}
}else{
print '<li>Unknown document type</li>';
}
}
$d->close();

?>
[/PHP]


problem is above code is its not check wethere $typ is file or directory
plz tell me how i can do that ?
and whats error in above code


sanjay
Jul 17 '07 #1
4 1641
mwasif
802 Recognized Expert Contributor
What do you get from this?
[PHP]filetype($entry )[/PHP]
Jul 17 '07 #2
Motoma
3,237 Recognized Expert Specialist
You might try something similar to this:
Expand|Select|Wrap|Line Numbers
  1.  
  2. function fileordir($what)
  3. {
  4.   if(is_file($what)) return 'file';
  5.   else if(is_dir($what)) return 'dir';
  6.   else return 'nothing';
  7. }
  8.  
Jul 17 '07 #3
sanjay123456
125 New Member
dear motoma ,

now i am using following code ......


[PHP]

$file=$path."\h tml\\";
$d = dir($file);
echo $file."<br/>";
while (false !== ($entry = $d->read())) {
echo $entry;
$typ = is_dir($entry);
echo $typ;
if($typ){
print '<li>[d]:'.$entry.'</li>';
}else if(!$typ){
$topic=explode( ".",$entry) ;
// $tname=$topic." .html";
if($topic[0] <> "") {
print '<li><input type="checkbox" name="check[]" value="'.$topic[0].'"><a href="edit.php? f='.$topic[0].'">'.$topic[0].'</a></li>';
}
}else{
echo "unknown";
}
}
$d->close();

?>

[/PHP]


but in this case its print single dot and double dot directory and
if html folder having some directory then its print as a file
is_dir function not checking properly .....
now what i am do ?


sanjay
Jul 18 '07 #4
Motoma
3,237 Recognized Expert Specialist
I believe:
$file=$path."\h tml\\";
is an error.

I think it should be:
$file=$path."\\ html\\";
Jul 18 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

0
2109
by: Dave Harrison | last post by:
Ok before I start, please dont mail me telling me to use a more recent version of Python, I _would_ use 2.2.x but due to an existing framework all based on using 2.1.1 I have been specifically told to use 2.1.1 to avoid any crossover issues/problems. Thanks ;-) So ... Using gcc Im compiling Python2.1.1, and it configures quite reasonably, the ./configure is trascribed at the bottom of this email. now once I have done that I compile it...
5
1113
by: matt dittman | last post by:
I have created a windows service that reads emails from a drop directory and moves them to the appropriate mail folder every 15 seconds. I can move, rename and delete the files as needed, up until the CDO.DropDirectory.GetMessages() method is called. At this point, the files are locked until I shut down the service. After processing and delivery, I need to be able to delete all the files in the drop directory. I can delete them via...
1
2941
by: Lentdave67t | last post by:
Thank you in advance for any help you can provide. I am writing a C# program that checks to see if the URLs of favorites/bookmarks are still good. The problem I am having is that while the program is checking the URLs, the text in a label on the current window will not update until after all URLs are checked. I think the Form/Window is frozen while the http requests are occuring. Does anyone know of a way I can update the Form in real...
2
1792
by: Lentdave67t | last post by:
Thank you in advance for any help you can provide. I am writing a C# program that checks to see if the URLs of favorites/bookmarks are still good. The problem I am having is that while the program is checking the URLs, the text in a label on the current window will not update until after all URLs are checked. I think the Form/Window is frozen while the http requests are occuring. Does anyone know of a way I can update the Form in real...
6
9268
by: Chad | last post by:
I am receiving the following two errors in the code below. Both are on Line 56. error C2039: 'CreateDirectoryA' : is not a member of 'System::IO::Directory' error C2660: 'CreateDirectoryA' : function does not take 1 arguments Could anyone please point me in thr right direction?
4
3334
by: gnah | last post by:
Greetings, I hope my problem is easy to fix, I'm pretty new with php - but I am getting weird results with the opendir() function. It may just be a path problem, but I don't see which variable to change. here are some tests I did to see what was wrong: $blah = opendir("blocks"); while ($file = readdir($blah)) {
11
3621
by: aldrin | last post by:
I'm trying to run this code under windows xp sp2 using codeblocks v1.0 compiler with great difficulty.There is no problem with running this under KDevelop in linux. Any help would be greatly appreciated. Enter an interesting string. Too many cooks spoil the broth Error opening C:\myfile.txt for writing. Program termnated. This application has requested the Runtime to terminate it in an unusual way.
5
9276
by: eoindeb | last post by:
I am trying to create a directory on Solaris using the mkdir() function. This works fine when I pass a string literal ("/etc/hosts") to mkdir, but if I try passing a directory pointer to mkdir, it returns a -1 error. The directory error works fine with fopen - does anyone know what I am doing wrong?? Here's a snippet of the code: int Check_Directory() //check for existence of directory - if not there, create the file { int status, ret...
11
1751
by: brianlanning | last post by:
We have a web application in 2003. The solution contains the project for the web application and five other projects for shared assemblies. We have two issues. The first is that we want to place the entire solution in some other directory like c:\work rather than wwwroot. We can use vss to do a get latest version, but as soon as we open the solution from within visual studio, vs copies the main web application source files to a new...
1
1921
by: halcyon943 | last post by:
have 4 folders that I watch and need to move files from to another location. Three constraints: -Finish time. Make sure the program stops transferring files at a specific time -Number of files transferred. Can only move a certain amount of files per time period. -Folders have a priority. The files have to be moved based on the folder priority.
0
9726
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9605
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10647
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10384
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10395
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6887
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4338
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3865
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3017
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.