HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/PvdBoogaard/indoorski.nl/backup/oude-site/cms/api/form/class.field.fileupload.php
<?php
/**
 * This file contains the iwp_field_fileupload class
 *
 * @package IWP
 * @subpackage IWP_FormFields
 */

/**
 * File Upload Field Class
 * This class is used by the api form class to generate a file upload field.
 *
 * @package IWP
 * @subpackage IWP_FormFields
 */

class iwp_field_fileupload extends iwp_field {
	/**
	 * This is the form field type of the field
	 *
	 * @var string
	 */
	public $type = 'fileupload';

	/**
	 * For holding whether the label should be shown for this field or not
	 *
	 * @var Boolean
	**/
	protected $showLabel = false;

	/**
	 * To hold the path to where the file(s) will be uploaded
	 *
	 * @var String
	**/
	protected $folder = '';

	/**
	 * Will hold any current files
	 *
	 * @var String
	**/
	protected $msg = '';

	/**
	 * Preference for using ajax or not
	 *
	 * @var boolean
	 */
	protected $ajax = true;

	/**
	 * __construct
	 * The constructor which calls the parent constructor that sets up the field name if it is passed in during the initialization
	 *
	 * @var string
	 */
	public function __construct($name=null) {
		parent::__construct($name);
	}

	/**
	 * GetFieldOutput
	 * Returns the HTML for this field. It generates the relevant parts, assigns them to template variables and returns a parse template file.
	 *
	 * @return string Returns the field HTML
	 */
	public function GetFieldOutput($setOnly=false) {
		$inputField = $this->Prepend . "<input type='file' name='" . iwp_htmlspecialchars($this->FieldName) . "' id='" . iwp_htmlspecialchars($this->FieldName) . "' ";
		$inputField .= $this->GetAttributes() . ' />'.$this->Append;

		parent::GetFieldOutput();

		$this->template->Assign('inputField', $inputField);
		$this->template->Assign('FieldName', $this->FieldName);
		$this->template->Assign('fileupload', array('ajax'=>$this->ajax));

		if(is_array($this->msg) && sizeof($this->msg) > 0) {
			while(list($name, $val) = each($this->msg)) {
				$this->template->Assign($name, $val);
			}
			reset($this->msg);
		}

		if(!$setOnly){
			return $this->template->ParseTemplate('form.fileupload', true);
		}
		return '';
	}

	/**
	 * Validate
	 * This is the function that data for this field is passed to to ensure it was submitted properly.
	 *
	 * @return string|boolean If the data is not valid, it will return false, if it is valid it will return a value
	 */
	public function Validate($arrData){
		return $arrData[$this->FieldName];
	}

	/**
	 * Turn off AJAX functionality for this fileupload field
	 *
	 */
	public function DisableAjax () {
		$this->ajax = false;
		return $this;
	}

	/**
	 * Turn on AJAX functionality for this fileupload field
	 *
	 */
	public function EnableAjax () {
		$this->ajax = true;
		return $this;
	}

	/**
	 * To set the folder for the uploading
	 *
	 * @param String $path The path of the folder
	**/
	public function SetFolder($path) {
		$this->folder = $path;
		return $this;
	}

	/**
	 * Will assign the provided name and message into the message array
	 *
	 * @param String $name The name to assign
	 * @param String $msg The value for the name above
	 */
	public function AddMessage($name, $msg) {
		$this->msg[$name] = $msg;
	}
}