Is the file there?

I need to find out the length of a file, or just find out if there is a file called “abc” in the folder, if the file is not there, it errors “Cant open file” “No such file”, how do i get around this

Also, i have a varible, A$
A$ = “BOB”
i need it to equal “‘A$’.V”
i tried to use A$ = A$ + “.v”, it doesn’t work, but it doesn’t error ???

To check if file exists, use the is_file() function. To find file size, use filesize() function. Here is an example:
[php]<?php
if(is_file(‘dir/myfile.txt’)){
echo ‘File size is: ‘.filesize(‘dir/myfile.txt’).’ bytes’;
}
else{
echo ‘No such file’;
}
?>[/php]

As for the second question, here is how to concatenate strings in php:
[php]$A = “BOB”;
$A = $A.".V";[/php]

if you want to simply check that a file exists in folder or not. this can be done simply using below code
[php]
//here i have created a folder having some text file.
//name of folder is docfolder
// put abc.txt file in it
//save this code as filecheck.php and run the code
//both filecheck.php and docfolder put at same location

$dir = ‘docfolder/’; //put ur folder path here
$filename = ‘abc.txt’; //put file name you want to check
$filecheck = $dir.$filename ;

if (file_exists($filecheck )) {
echo “The file $filename exists”;
} else {
echo “The file $filename does not exist”;
}
[/php]

i think this is help for you.

Sponsor our Newsletter | Privacy Policy | Terms of Service