public function downloadFile($filePath, $suggestedFilename, $mimeType = null) {
		// if the file exists at the specified path
		if (\file_exists($filePath) && \is_file($filePath)) {
			// if no MIME type has been provided explicitly
			if ($mimeType === null) {
				// use a reasonable default value
				$mimeType = 'application/octet-stream';
			}

			// send the appropriate response headers for the download
			self::sendDownloadHeaders($mimeType, $suggestedFilename, filesize($filePath));

			// pipe the actual file contents through PHP
			readfile($filePath);
		}
		// if the file could not be found
		else {
			throw new \RuntimeException('File `'.$filePath.'` not found');
		}
	}
public function downloadFile($filePath, $suggestedFilename, $mimeType = null) {
		// if the file exists at the specified path
		if (\file_exists($filePath) && \is_file($filePath)) {
			// if no MIME type has been provided explicitly
			if ($mimeType === null) {
				// use a reasonable default value
				$mimeType = 'application/octet-stream';
			}

			// send the appropriate response headers for the download
			self::sendDownloadHeaders($mimeType, $suggestedFilename, filesize($filePath));

			// pipe the actual file contents through PHP
			readfile($filePath);
		}
		// if the file could not be found
		else {
			throw new \RuntimeException('File `'.$filePath.'` not found');
		}
	}
public function downloadFile ( $ filePath , $ suggestedFilename , $ mimeType = null ) { // if the file exists at the specified path if ( \ file_exists ( $ filePath ) && \ is_file ( $ filePath ) ) { // if no MIME type has been provided explicitly if ( $ mimeType === null ) { // use a reasonable default value $ mimeType = 'application/octet-stream' ; } // send the appropriate response headers for the download self :: sendDownloadHeaders ( $ mimeType , $ suggestedFilename , filesize ( $ filePath ) ) ; // pipe the actual file contents through PHP readfile ( $ filePath ) ; } // if the file could not be found else { throw new \ RuntimeException ( 'File `' . $ filePath . '` not found' ) ; } }
Sends the specified file to the client and prompts a download

@param string $filePath the path to the file that should be downloaded
@param string $suggestedFilename the suggested name to save the file with (including an extension), e.g. `my-photo.jpg`
@param string|null $mimeType (optional) the MIME type for the download, e.g. `image/jpeg`
Sends the specified file to the client and prompts a download