Home arrow PHP arrow How to Split a File During an FTP Upload Using PHP

How to Split a File During an FTP Upload Using PHP

One of the known limitations of free hosting packages is the file upload limit. For example, some hosting companies set an upload limit of 500 KB. This means that for any uploads to the FTP server, the file should not be more than 500 KB or else the server won’t accept it and you will not be able to upload your file. Fortunately, by splitting your files, you can get around this limitation; this two-part tutorial series will show you how.

TABLE OF CONTENTS:
  1. How to Split a File During an FTP Upload Using PHP
  2. Inside the Split Folder Directory
  3. PHP File Splitting Script: splitthisfile.php
  4. Using the File Splitting Function
By: Codex-M
Rating: starstarstarstarstar / 3
November 17, 2009

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

Of course, some files that are important for web site functionality exceed 500 KB. For example, if you are running a web application that needs a geo IP database, a typical file for the geo IP DAT file is around 1.1MB. So this cannot be uploaded as one batch because it exceeds the upload limit of 500 KB. Another common example is uploading music or videos such as MP3, wav or .WMV files.

There is no easy way to break down a file like this (especially if the web hosting company does not allow uploading of archives like .zip, .rar), and technical solutions are needed to upload this file as a single batch without switching to another hosting agency, which can be inefficient in some cases.

As mentioned in the introduction, this is the first part of a two-part tutorial series. In this part, you will learn how to create the PHP split file script.

Concept of Implementation

To provide a glimpse of how you are going to implement the splitting and merging of files, see the flowchart below:

You need XAMPP installed in your computer. If you are using a Windows-based operating system, you can read a tutorial that will help guide you through the installation process. 

The "split folder" directory contains the "PHP File splitting script" which will be discussed in this tutorial. Also, the script is a web form which will ask for the name of the file as well as the FTP server maximum file upload limit in kilobytes. You can get this data from your web hosting agency. Make sure the data is in kilobytes (KB).

Once the split file script has been executed by submitting the form, several parts of the file will be created. This means that the file will be split into "N" parts based on the file size and the upload limit. Details of this process will be covered later.

After the file has been split successfully, it can be uploaded easily to your hosting FTP server because it is now less than the maximum file upload limit. You are going to upload it to the desired location in your FTP server.

Along with the file to be uploaded is the "PHP merge script," which is also a web form that asks for merge file settings, such as your exact file name and the number of parts into which the file has been split (these will be discussed thoroughly in the second part of this series).

After executing the file merging script, the parts of the split files will be combined into one (back to the original file, but this time in the FTP server, NOT in your local host directory). The remnants or remains of the split parts, however, will still be there in your FTP server. In that case, you can simply delete those fragments after successful file merging.

It is also safe to delete the PHP merge script once the merging has been completed to prevent unauthorized use.



 
 
>>> More PHP Articles          >>> More By Codex-M
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

PHP ARTICLES

- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: