While reading the files in PHP, I am able to read only those files which are in my xampp or htdocs folder. If I want to read a file from other directory say D: or E: or desktop (other than my xampp directory), my script fails.
My code for file reading :
$handle = fopen($filename, "r");
$contents = fread($handle, filesize($filename));
$filesize = filesize($filename);
If I try to read a file from other directory(other than my xampp directory) I get following errors:
Warning: fopen(sem 8 sylabus.txt) [function.fopen]: failed to open stream: No such file or directory in D:\xampp\htdocs\BE\indexing.php on line 347
Warning: filesize() [function.filesize]: stat failed for sem 8 sylabus.txt in D:\xampp\htdocs\BE\indexing.php on line 348
Warning: fread() expects parameter 1 to be resource, boolean given in D:\xampp\htdocs\BE\indexing.php on line 348
Warning: filesize() [function.filesize]: stat failed for sem 8 sylabus.txt in D:\xampp\htdocs\BE\indexing.php on line 349
Please suggest an alternative method to handle this error!