Jump to content

file /directory problem


sheraz

Recommended Posts

this code is creating a directory and copying a file in it. now i want to show the contents of this newly created file. but it is not working. please help me.

Here is the code.

 

 

<?php

 

$dir_name=$_POST['dirname'];

 

$dir_path="c:\wamp\www";

 

if( file_exists($dir_path) )

{

if(! ($dp=opendir($dir_path) ) )

die("could not open directory.");

else

{

if( mkdir("$dir_path\ $dir_name", 0777) )

echo "The Directory $dir_name has been created";

else

echo $dir_name . "has not been created";

}

copy("$dir_path\abc.txt","$dir_path/$dir_name/abc.txt");

$drpath="$dir_name/$dir_name";

chdir($drpath);

while($file=readdir($dp) )

{

if( $file!='.' && $file!='..')

{

echo $file . "<br>";

}

 

}

}

else

{

echo "Sorry file/directory does not exists";

}

?>

Link to comment
https://forums.phpfreaks.com/topic/174407-file-directory-problem/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.