Use PHP to create a secure Internet file-sharing application that employs a database abstraction layer and separates HTML design from PHP programming.

WEBINAR:

On-Demand

Installation Instructions for a Quick Start
The server infrastructure for the example program requires a web server that can run PHP code, and the PHP interpreter has to be compiled with the support of the selected RDBMS. In my case, I chose the LAMP framework: Linux (Debian), Apache, MySQL and, obviously, PHP. The following installation instructions assume you have working installs of Apache 2.X, PHP 5.X, and MySQL 4.X, as well as an Internet connection.

To begin, download the accompanying source code for this article, and extract the file_sharing.zip file under the web server documents root (from now on [document_root]) with the following command:

unzip file_sharing.zip

PEAR MDB2 Installation
The installation of PEAR packages requires an installer that you already have available if you installed PHP version 4.3.0 or higher. If so, you just run this on the command line:

pear install MDB2
pear install MDB2#mysql

Smarty Installation
To install the Smarty template engine (more on Smarty later), run the following if you are a Debian user:

Setting Configuration Variables
As the file inc.config.php in the source code download explains, there are global variables specific to local installation. Set these variables as suggested in Table 1 below.

Table 1. Suggested Settings for Configuration Variables: These are global variables specific to local installation.

Value

Value

$smarty_include_path

[installation_dir]/smarty/libs

$pear_include_path

where PEAR installation copies MDB2.php file

$overlib_path

/overLIB

$template_dir

[document_root]/file_sharing/smarty/templates

$config_dir

[document_root]/file_sharing/smarty/configs

$cache_dir

[installation_dir]/smarty/cache

$compile_dir

[installation_dir]/smarty/templates_c

$dsn

mysql://db_user:db_password@db_server/file_sharing

When all the above installations are complete, you can call http://yourserver/file_sharing/file_sharing.php (see Figure 1) and start to upload files (see Figure 2).

Figure 1. File-Sharing Application Home Page: This figure shows the uploaded and tagged files with the list of used tags.

Figure 2. File-Sharing Action Pop-Up: This figure shows the pop-up opened after clicking on a file.

Author's Note: Versions 6 and 7 of Internet Explorer send the inner text of a button instead of its value, which is counter to the W3C recommendation. So if you would like to use these IE versions for this example, you have to replace all <button> instances in .tpl files with <input>, which will sacrifice some CSS benefits.

Advertiser Disclosure:
Some of the products that appear on this site are from companies from which QuinStreet receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. QuinStreet does not include all companies or all types of products available in the marketplace.

Thanks for your registration, follow us on our social networks to keep up-to-date