# Read txt file inside a directory

**URL:** <https://forum.kirupa.com/t/read-txt-file-inside-a-directory/252810>\
**Category:** programming\
**Created:** [February 23, 2008, 9:27pm UTC](https://forum.kirupa.com/t/read-txt-file-inside-a-directory/252810 "2008-02-23T21:27:56Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jespschultz](https://avatars.discourse-cdn.com/v4/letter/j/13edae/32.png) [@jespschultz](https://forum.kirupa.com/u/jespschultz)\
**Post date:** [February 23, 2008, 9:27pm UTC](https://forum.kirupa.com/t/read-txt-file-inside-a-directory/252810/1 "2008-02-23T21:27:56Z")

</div>

I’m not very familiar with PHP, and have what I’m sure is a very simple question. I’ve been trying to find the anwser in a thread somewhere but can’t seem to find it. All I want to do is open a txt file read from inside a directory. Here is the basic idea of what I’m doing. This is being used from Saurdo’s php photo gallery ([www.saurdo.com](http://www.saurdo.com))

$curdirsplt = split(’/’, $dirpath1);  
$currentdir = $curdirsplt[count($curdirsplt)-1];

$desc = $currentdir. “/description.txt”;  
$fh = fopen($desc, ‘r’);

When I run this function, I receive an error that says “DirectoryNamedescription.txt does not exist” like its adding the directory name to the text file name. All I want it to do is open the text file inside of the folder.

Any help would be greatly appreciated.

Thanks  
J
