Introduction
In this article I describe the PHP FileSystem functions is_readable, is_uploaded, is_writable and is_writeable. To learn some other FileSystem functions, go to:
- FileSystem Function in PHP: PART 1
- FileSystem Function in PHP: PART 2
- FileSystem Function in PHP: PART 3
- FileSystem Function in PHP: PART 4
- FileSystem Function in PHP: PART 5
- FileSystem Function in PHP: PART 6
- FileSystem Function in PHP: PART 7
- FileSystem Function in PHP: PART 8
- FileSystem Function in PHP: PART 9
- FileSystem Function in PHP: PART 10
- FileSystem Function in PHP: PART 11
- FileSystem Function in PHP: PART 12
PHP is_readable() Function
The PHP FileSystem is_readable function checks whether a file exists and is readable and it returns true if the file or directory specified by the filename exists and is readable or false on failure.
Syntax
Parameter in is_readable function
The parameter of the function is:
Parameter |
Description |
file |
It specifies the file to check. |
Example
An example of the function is:
<?php
$file = "test.txt";
if(is_readable($file))
{
echo ("$file is <b>readable.</b>");
}
else
{
echo ("$file is not <b>readable.</b>");
}
?>
Output
PHP is_uploaded() Function
The PHP FileSystem is_readable function checks whether the file was uploaded via HTTP POST and it returns true on success and false on failure.
Syntax
Parameter in is_uploaded function
The parameter of the function is:
Parameter |
Description |
file |
It specifies the file to check. |
Example
An example of the function is:
<?php
$file = "test.txt";
if(is_uploaded_file($file))
{
echo ("$file is uploaded via HTTP POST.");
}
else
{
echo ("$file is not uploaded via HTTP POST.");
}
?>
Output
PHP is_writable() Function
The PHP FileSystem is_writable function checks whether the filename is writable and it returns true if the filename exists and is writable.
Syntax
Parameter in is_writable function
The parameter of the function is:
Parameter |
Description |
file |
It specifies the file to check. |
Example
An example of the function is:
<?php
$file = "test.txt";
if(is_writable($file))
{
echo ("$file is writable.");
}
else
{
echo ("$file is not writable.");
}
?>
Output
PHP is_writeable() Function
It is an alias of the is_writable function and it is also used to determine if the filename is writeable and it returns true if the filename exists and is writeable.
Syntax
Parameter in is_writeable function
Parameter |
Description |
file |
It specifies the file to check. |
Example
An example of the function is:
<?php
$file = "test.txt";
if(is_writeable($file))
{
echo ("$file is writeable.");
}
else
{
echo ("$file is not writeable.");
}
?>
Output