Reader Level:
ARTICLE

FileSystem Function in PHP: Part 13

Posted by Sharad Gupta Articles | PHP April 08, 2013
In this article I describe the PHP FileSystem functions is_readable, is_uploaded, is_writable and is_writeable.
  • 0
  • 0
  • 1712

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:

  1. FileSystem Function in PHP: PART 1
  2. FileSystem Function in PHP: PART 2
  3. FileSystem Function in PHP: PART 3
  4. FileSystem Function in PHP: PART 4
  5. FileSystem Function in PHP: PART 5
  6. FileSystem Function in PHP: PART 6
  7. FileSystem Function in PHP: PART 7
  8. FileSystem Function in PHP: PART 8
  9. FileSystem Function in PHP: PART 9
  10. FileSystem Function in PHP: PART 10
  11. FileSystem Function in PHP: PART 11
  12. 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

is_readable(file)

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

is-readable-function-in-php.jpg

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

is_uploaded(file)

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

is_uploaded-function-in-php.jpg

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

is_writable(file)

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

 
is-writable-function-in-php.jpg

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

is_writeable(file)

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

is-writeable-function-in-php.jpg

COMMENT USING

Trending up