public function upload($array)
	{
		$array['action'] = 'upload';
		$array['format'] = 'php';

		// Construct multipart body: https://www.mediawiki.org/wiki/API:Upload#Sample_Raw_Upload
		$boundary = '---Wikimate-' . md5(microtime());
		$body = '';
		foreach ($array as $fieldName => $fieldData) {
			$body .= "--{$boundary}\r\n";
			$body .= 'Content-Disposition: form-data; name="' . $fieldName . '"';
			// Process the (binary) file
			if ($fieldName == 'file') {
				$body .= '; filename="' . $array['filename'] . '"' . "\r\n";
				$body .= "Content-Type: application/octet-stream; charset=UTF-8\r\n";
				$body .= "Content-Transfer-Encoding: binary\r\n";
			// Process text parameters
			} else {
				$body .= "\r\n";
				$body .= "Content-Type: text/plain; charset=UTF-8\r\n";
				$body .= "Content-Transfer-Encoding: 8bit\r\n";
			}
			$body .= "\r\n{$fieldData}\r\n";
		}
		$body .= "--{$boundary}--\r\n";

		// Construct multipart headers
		$headers = array(
			'Content-Type' => "multipart/form-data; boundary={$boundary}",
			'Content-Length' => strlen($body),
		);

		$apiResult = $this->session->post($this->api, $headers, $body);

		return unserialize($apiResult->body);
	}