# css-javascript-toolbox/8.2/controllers/package-file.php

CSS &amp; JavaScript Toolbox, version 8.2. 66 lines.

- Page: https://pluginprobe.com/plugins/css-javascript-toolbox/8.2/code/controllers/package-file.php
- Raw: https://pluginprobe.com/plugins/css-javascript-toolbox/8.2/raw/controllers/package-file.php
- Modified: 2016-03-05T15:13:58+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/css-javascript-toolbox/8.2/code/controllers/package-file.php#L10-L20`.

```php
<?php
/**
* @version $ Id; ?FILE_NAME ?DATE ?TIME ?AUTHOR $
*/

// Disallow direct access.
defined('ABSPATH') or die("Access denied");

// import dependencies.
cssJSToolbox::import('framework:mvc:controller-ajax.inc.php');

/**
* 
* DESCRIPTION
* 
* @author ??
* @version ??
*/
class CJTPackageFileController extends CJTAjaxController {
	
	/**
	* put your comment there...
	* 
	* @var mixed
	*/
	protected $controllerInfo = array('model' => 'package-file');
	
	/**
	* 
	* Initialize new object.
	* 
	* @return void
	*/
	public function __construct() {
		// Initialize parent!
		parent::__construct();
		// Add actions.
		$this->registryAction('install');
	}

	/**
	* put your comment there...
	* 
	*/
	protected function installAction() {
		// Initialize.
		$model =& $this->model;
		// Unzip and Parse package file when uploaded.
		if ($_SERVER['REQUEST_METHOD'] == 'POST') {
			// Get uploaded file.
			$file = $_FILES['fileToUpload'];
			try {
				// Parse/Unzip+Parse definition the package file.
				$package = $model->parse($file['name'], $file['tmp_name']);
				// Install package
				$packageId = $model->install($package);
			}
			catch (Exception $exception) {
				$this->model->setState('error', array('msg' => $exception->getMessage()));
			}
		}
		// Display uploader!
		parent::displayAction();
	}

} // End class.
```
