File Operations PHP Tutorials
The input and output in a web application usually flow between browser, server, and database,
but there are many circumstances in which files are involved too. Files are useful for retrieving
remote web pages for local processing, storing data without a database, and saving information that other programs need to access. Learn how to: handle file uploads, restrict the size and type of uploads, prevent files from being overwritten, organize uploads into specific folders, handle multiple uploads and more.
Creating a Zip File
PHP tutorial: Learn how to compress/archive mySql data or files on the fly using PHP.
Force download files
Hello guys here is a simple yet powerful script that allows you guys to force the users download some files with the dialog box Do you want to open or save the file, just copy paste the script.
Create Nice-Looking PDFs with PHP and FPDF
Learn how to use the free FPDF library to produce great-looking PDF documents from within your PHP scripts. Full example included.
Creating a Flat File Hit Counter
You must be comfortable uploading files to your server via FTP. I recommend at a bare minimum being familiar with variables and functions.
How to allow users upload files to server
In this post I will explain how to allow our visitors or site admin to upload files to our web server using html forms and php syntax.
I will also show how to block harmful files and prevent them from being uploaded.
How to Parse a CSV File
In this tutorial you will learn a simple way to parse CSV files using PHP and output the text of the fields you need. This tutorial is not going to go into what you can do with the data once you get it from the CSV as the possibilities are endless.
Viewing All Files in a Directory
PHP can do many, many things, of course everyone knows of MySQL interaction, but on its own PHP can do almost anything, with very little assistance from other programs or database engines.
Get the directory name and filename from a full path name
It's easy to get the filename and directory name components of a full path name with PHP using the dirname(), basename() and pathinfo() functions. The latter also contains the filename extension.
Read CSS files
This function will open CSS file read it's styles and separate selectors from property value pairs. The function stores the values in two array sessions (names and styles). The values can be then easily retrieved using loops or if/else statements.
Write and append to files with file_put_contents
The PHP file_put_contents() function is a useful shortcut for dumping a string into a file (compared with using fopen, fputs etc). By default it will create a new file if it does not exist, or overwrite the file if it does exist. Recently I re-read the documentation for this function and discovered it is also possible to append to a file with file_put_contents.
File Downloads with Speed Limit
PHP can be used to securely control access to file downloads. This tutorial will show how you can send file through a PHP script and limit the download rate. The function we will write accepts the path to the file to send and optionally a rate in kB/s to limit the transfer speed. The function should also be able to handle range headers from clients that allow stopping and resuming downloads.
Easily finding duplicate files
Some days ago I was asked by my mother if there was an easy way to find duplicate photos on her computer. I thought about it and I came up with the idea that the easiest way to do this is to just compare if some hash matches between the files (which works fine as long the images are not modified). Then came the implementation and I thought since I know PHP best for this job, why not use it. Now I know that PHP hasnt much of a reputation as a command line scripting language, but bear with me .
Reading the clean text from DOCX and ODT
In this article we will resolve the task of reading the plain text from the Office Open XML (more known as DOCX) and OpenDocument Format ODT using PHP. Note that we are not going to apply any third-party software.
Reading the clean text from RTF
Rich Text Format (often abbreviated as RTF), to surprise of many, is quite complex text data format. Let's read the plain text from RTF file.
Reading the clean text from PDF
Portable Document Format (PDF) is a file format created for the document exchange. Let's read the plain text from PDF file.
