PHP File Operations Summary (delete the specified file/Get folder under the file name/Read folder under the picture name), _php tutorial

Source: Internet
Author: User
Tags getting started with php

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 ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.