Categories
PHP

Using Relative Paths for File Access

Usually, files are opened (or searched) relative to the path of the document. To be sure that you are searching for the current script’s path, you can use a two-step approach: The constant __FILE__ contains the full path of the current script, and the function dirname() determines the directory name portion of a path.

Categories
PHP

ZipArchive – Zip and Unzip Files and Folders

Let’s create a compressed Zip archive in PHP with ZipArchive class, which provides many features for reading and writing Zip archives.

Categories
PHP

Zipping and Unzipping a File with Zlib and Bzip2

How to compress files in PHP with compress.zlib:// and compress.bzip2:// streams (and with gzopen() and bzopen()).

Categories
PHP

Recursive Directory Iterator

How to use DirectoryIterator and RecursiveDirectoryIterator classes to loop through all files and folders inside a directory.

Categories
PHP

Reading Directories Contents

How to browse the file system with the help of PHP functions.

Categories
PHP

Copying, Moving and Deleting Files

Learn how to rename, move, copy or delete files in PHP.

Categories
PHP

Reading Information About Files

Learn how to get all file information, for example, get modification time with filemtime(), get last access time with fileatime(), get group id with filegroup(), get user id with fileowner(), get size with filesize() and use the stat() function to get all information (meta data) about a file.

Categories
PHP

File Permission

Learn how to use the is_executable(), is_readable(), is_writable(), fileperms(), and chmod() functions to determine whether your PHP script has permission to execute, read or write a particular file.

Categories
PHP

Check File Type (whether a file is a directory or a file)

How to check the type of a file. For example, check whether the provided file name is a directory, a file, or a symbolic link.

Categories
PHP

Parsing INI Strings and Files

Let’s write the PHP configuration information, such as the database host and user credentials, in an INI file. Then use the parse_ini_file() function to parse this information in your web application.