public function validate_upload(UploadedFile $file) {
		foreach ($this->restrictions as $k => $v) {
			switch ($k) {
				case 'maxsize':
					if ($v < $file->get_size()) {
						throw new Exception('Received file was too large.', Exception::ERR_BAD_REQUEST);
					}
					break;

				case 'mediatype':
					if (!in_array($file->get_mediatype(), $v)) {
						throw new Exception('Files with that extension are not allowed.', Exception::ERR_BAD_REQUEST);
					}
					break;

				case 'mimetype':
					if (!in_array($file->get_type(), $v)) {
						throw new Exception('Files with that extension are not allowed.', Exception::ERR_BAD_REQUEST);
					}
					break;

				case 'extension':
					if (!in_array($file->get_file_extension(), $v)) {
						throw new Exception('Files with that extension are not allowed.', Exception::ERR_BAD_REQUEST);
					}
					break;
			}
		}
		return true;
	}
public function validate_upload(UploadedFile $file) {
		foreach ($this->restrictions as $k => $v) {
			switch ($k) {
				case 'maxsize':
					if ($v < $file->get_size()) {
						throw new Exception('Received file was too large.', Exception::ERR_BAD_REQUEST);
					}
					break;

				case 'mediatype':
					if (!in_array($file->get_mediatype(), $v)) {
						throw new Exception('Files with that extension are not allowed.', Exception::ERR_BAD_REQUEST);
					}
					break;

				case 'mimetype':
					if (!in_array($file->get_type(), $v)) {
						throw new Exception('Files with that extension are not allowed.', Exception::ERR_BAD_REQUEST);
					}
					break;

				case 'extension':
					if (!in_array($file->get_file_extension(), $v)) {
						throw new Exception('Files with that extension are not allowed.', Exception::ERR_BAD_REQUEST);
					}
					break;
			}
		}
		return true;
	}
public function validate_upload ( UploadedFile $ file ) { foreach ( $ this -> restrictions as $ k => $ v ) { switch ( $ k ) { case 'maxsize' : if ( $ v < $ file -> get_size ( ) ) { throw new Exception ( 'Received file was too large.' , Exception :: ERR_BAD_REQUEST ) ; } break ; case 'mediatype' : if ( ! in_array ( $ file -> get_mediatype ( ) , $ v ) ) { throw new Exception ( 'Files with that extension are not allowed.' , Exception :: ERR_BAD_REQUEST ) ; } break ; case 'mimetype' : if ( ! in_array ( $ file -> get_type ( ) , $ v ) ) { throw new Exception ( 'Files with that extension are not allowed.' , Exception :: ERR_BAD_REQUEST ) ; } break ; case 'extension' : if ( ! in_array ( $ file -> get_file_extension ( ) , $ v ) ) { throw new Exception ( 'Files with that extension are not allowed.' , Exception :: ERR_BAD_REQUEST ) ; } break ; } } return true ; }
Validate an UploadedFile object against the list of restrictions.

@param UploadedFile $file An UploadedFile object to validate.
@return bool True if successful.
Validate an UploadedFile object against the list of restrictions .