Files

Files are the basic unit of data storage in an operating system, and have many variations of format and function across file types and operating systems. Files also have two levels of attributes, at the operating system level, and within applications. This chapter covers basic file types, attributes common to all file types, PHP code to work with files, and the basis for file access in other chapters, like the sessions described in Chapter 19.

This chapter contains the following sections:

  In Depth
    Directories
        Apache's View
        PHP's View
        Changing Views
    File Types
        Displaying Files
        Creating and Changing Files
        Copying Files
        Temporary Files
    Uploading Files
    The File Cache List
    Permissions
  Immediate Solutions
    Listing Directories
        Common Code
        The is_dir() Approach
        The filetype() Approach
        The get_directory_file() Approach
        Formatted File List
        Other Directory Functions
    Creating and Deleting Directories
    Listing Files with Attributes
        Common Code
        get_directory_file() Expanded
        Formatted File List
        Additional Attributes
    Reporting Disk Space
        Common Code
        get_directory_file() Expanded
        Finding Free Disk Space
        Formatting the File Lsit with Space Used
        Listing Space Used by Directory
        Listing Space Used by Largest Directories
        Listing Space Used by Largest Files
    Listing Image File Attributes
        Collecting Image Information
        Displaying Image Information
    Displaying Any Data
        Common Code
        Displaying a Text File
        Displaying a HTML File
        Displaying Any File
    Uploading Files
    Calculating CRCs for Files

Updates and Additions

Updated and additional sections are in the following list.