Example of php detecting file read-only, writable, and executable permissions

WBOY
Release: 2016-07-25 08:56:14
Original
944 people have browsed it
  1. $myfile = "./test.txt";

  2. if (is_readable ($myfile)) {

  3. echo "This file Readable. ", "n";
  4. } else {
  5. echo "This file is not readable.", "/n";
  6. }
  7. if (is_writable ($myfile)) {
  8. echo "This file is writable." , "/n";
  9. } else {
  10. echo "This file is not writable.", "/n";
  11. }

  12. if (is_executable ($myfile)) {

  13. echo "This File is executable!", "n";
  14. } else {
  15. echo "This file does not have executable permissions", "n";
  16. }
  17. ?>

Copy code

Attached, detect the size of the file and learn how to use filesize.

  1. $myfile = "./test.txt";

  2. if (file_exists ($myfile)) {

  3. $checksize= filesize ($myfile);
  4. echo "$checksize";
  5. } else {
  6. echo "File does not exist!";
  7. }
  8. ?>

Copy code


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!