PHP File Operations Summary (delete the specified file/Get folder under the file name/read the folder name),
This paper analyzes the methods of PHP file operation. Share to everyone for your reference, as follows:
First, delete the file
Unlink ()
Syntax: int unlink (string filename);
return value: Integer
Function type: file access. Such as:
Unlink ("Tmp/test.txt");
Second, get the file name under the folder
$dir = "message/"; The name of the folder if (Is_dir ($dir)) { if ($dh = Opendir ($dir)) {while (($file = Readdir ($DH))!== false) {
"; } Closedir ($DH); }}
Third, read the picture name under the folder
<?php$handle = Opendir (' images/'); Current directory while (false!== ($file = Readdir ($handle))) {//traverse the directory where the php file is located list ($filesname, $KZM) =explode (".", $file) ;//Get extension if ($kzm = = "gif" or $kzm = = "jpg" or $kzm = = "jpg") {//File filter if (!is_dir ('./'. $file)) {//folder filter $array [] = $file;//Put the eligible file name into the array $i ++;//record the total number of pictures}}} print_r ($array);? >
More about PHP related content readers can view the topic: "PHP File Operation Summary", "PHP operation and operator Usage Summary", "PHP Network Programming Skills Summary", "PHP Basic Grammar Introductory Tutorial", "PHP operation Office Document tips summary (including word, excel,access,ppt), "PHP Date and Time usage summary", "PHP primer for Object-oriented programming", "PHP String Usage Summary", "Getting Started with Php+mysql database operations" and "PHP Common Database Operations Skills Summary"
I hope this article is helpful to you in PHP programming.
http://www.bkjia.com/PHPjc/1125903.html www.bkjia.com true http://www.bkjia.com/PHPjc/1125903.html techarticle PHP File Operation Summary (delete the specified file/Get folder under the file name/Read folder name), this article analyzes the PHP file operation method. Share to everyone for your reference ...