english/administrator/components/com_aicontactsafe/models/attachments.php
// download a file from the attachments folder
download a file from the attachments folder
download a file from the attachments folder
function downloadFile() {
		$file_name = JRequest::getCmd('file', '');
		$upload_folder = str_replace('\\',DS,$this->_config_values['upload_attachments']);
		$upload_folder = str_replace('/',DS,$upload_folder);
		$upload_folder = str_replace('&#92;',DS,$upload_folder);
		$path_upload = JPATH_ROOT.DS.$upload_folder;
		$file = $path_upload.DS.$file_name;
		if ( strlen(trim($file_name)) > 0 && file_exists($file) ){
			$this->ob_clean_all(); 
			header('Content-Description: File Transfer');
		    header('Content-Type: application/octet-stream');
		    header('Content-Disposition: attachment; filename='.basename($file));
		    header('Content-Transfer-Encoding: binary');
		    header('Expires: 0');
		    header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
		    header('Pragma: public');
		    header('Content-Length: ' . filesize($file));
		    @ob_clean();
		    flush();
			readfile($file);
			exit;
		} else {
			echo '<script type="text/javascript" language="javascript">alert(\''.JText::_('COM_AICONTACTSAFE_FILE_WAS_DELETED').'\');</script>';
		}
	}
function downloadFile ( ) { $ file_name = JRequest :: getCmd ( 'file' , '' ) ; $ upload_folder = str_replace ( '\\' , DS , $ this -> _config_values [ 'upload_attachments' ] ) ; $ upload_folder = str_replace ( '/' , DS , $ upload_folder ) ; $ upload_folder = str_replace ( '&#92;' , DS , $ upload_folder ) ; $ path_upload = JPATH_ROOT . DS . $ upload_folder ; $ file = $ path_upload . DS . $ file_name ; if ( strlen ( trim ( $ file_name ) ) > 0 && file_exists ( $ file ) ) { $ this -> ob_clean_all ( ) ; header ( 'Content-Description: File Transfer' ) ; header ( 'Content-Type: application/octet-stream' ) ; header ( 'Content-Disposition: attachment; filename=' . basename ( $ file ) ) ; header ( 'Content-Transfer-Encoding: binary' ) ; header ( 'Expires: 0' ) ; header ( 'Cache-Control: must-revalidate, post-check=0, pre-check=0' ) ; header ( 'Pragma: public' ) ; header ( 'Content-Length: ' . filesize ( $ file ) ) ; @ ob_clean ( ) ; flush ( ) ; readfile ( $ file ) ; exit ; } else { echo '<script type="text/javascript" language="javascript">alert(\'' . JText :: _ ( 'COM_AICONTACTSAFE_FILE_WAS_DELETED' ) . '\');</script>' ; } }
download a file from the attachments folder
download a file from the attachments folder
// get the name of the file // get the path to attachments upload // start the file download // Make sure there's not anything else left for download