/**
	 * File clean up process manager
	 *
	 * @return boolean true, if file passes all checks
	 */
	private function cleanFile() {
		$this->file['name'] = $this->cleanFilename($this->file['name']);
		$this->file['width'] = $this->getImageWidth($this->file['tmp_name']);
		$this->file['height'] = $this->getImageHeight($this->file['tmp_name']);
		$this->file['type'] = strtolower($this->file['type']);

		// find the best extension; PHP can figure out what images SHOULD use, or try MIME,
		$extension = '';
		$uploadFile = new File($this->file['name']);
		$supplied_extension = $uploadFile->extension();
		$basename = $uploadFile->name(false);

		if (stripos($this->file['type'], "image/") === 0) {
			$image_extension = $this->getImageExtension($this->file['tmp_name']);

			if ($supplied_extension == $image_extension) {
				// filename's extension matched what PHP thought it should be
				$extension = $image_extension;
			}
			else {
				// mismatch: user uploaded 'foo.gif'; PHP thinks it's a jpg; call it 'foo.gif.jpg'
				$basename  = $basename.'.'.$supplied_extension;
				$extension = $image_extension;
			}
		}
		elseif ($supplied_extension) {
			$extension = $supplied_extension;
		}
		elseif ($this->file['type'] != 'application/octet-stream') {
			// suggest ext, based on MIME, but not for generel type application/octet-stream
			$extension = MimeType::getExtensions($this->file['type'], true);
		}

		// last resort, use default_extenstion by setDefaultExtension()
		if (!$extension) {
			$extension = $this->default_extension;
		}

		// correct file array
		$this->file['extension'] = $extension;
		$this->file['basename'] = $basename;
		$this->file['name'] = $this->file['basename'].'.'.$this->file['extension'];

		return true;
	}