You are viewing documentation for an outdated version. It is no longer supported!
Filename
Available since v7.4.x
There are two methods for obtaining the filename. The first is uri()
, which return the uri
metadata. The second is filename()
, which returns the file's basename, or a custom filename
entry from the stream's metadata.
$stream = FileStream::open('houses.txt', 'rb');
echo $stream->uri(); // /home/my_user/files/houses.txt
echo $stream->filename(); // houses.txt
If you specify a custom filename
metadata, then it will be favoured instead of the basename.
$stream = FileStream::open('houses.txt', 'rb');
$stream->meta()->set('filename', 'my_file.txt');
echo $stream->uri(); // /home/my_user/files/houses.txt
echo $stream->filename(); // my_file.txt