file check
Posted: Sun Sep 24, 2006 5:46 am
I wanted to check if a file exist in a directory and if it doent exist the flie should be created and if it does exist the user should be told to change the name of the file he or she intends to create in the directory.
I tried the below script but if the file doesn't exist, i receive this error;
Warning: file(ient.php) [function.file]: failed to open stream: No such file or directory in E:\Webserver\xampplite\htdocs\text\index.php on line 3
So I need help on this script so I dont receive the error.
I tried the below script but if the file doesn't exist, i receive this error;
Warning: file(ient.php) [function.file]: failed to open stream: No such file or directory in E:\Webserver\xampplite\htdocs\text\index.php on line 3
So I need help on this script so I dont receive the error.
Code: Select all
<?
$filename = $_POST["filename"].".txt";
if (file($filename) == null) {
echo "file not found";
}
else {
echo "file exists in the directory";
}
?>