phpBB

Development Wiki

Send file to browser

From phpBB Development Wiki

send_file_to_browser –– Send file to browser.

Description

void send_file_to_browser ( $attachment , $upload_dir , $category )

Deliver a file to the browser.

Parameters

Parameter Usage
attachment Array containing the following information:
  • physical_filename
  • mimetype
  • real_filename
  • filetime
upload_dir Upload directory containing the file, relative to the phpbb_root_path.
category This function checks if $category != ATTACHMENT_CATEGORY_IMAGE and corrects the mime type - we force application/octetstream for all files, except images.

Return Values

Void

Examples

Example #1

Basic usage example.

// Determine the 'presenting'-method
if ($download_mode == PHYSICAL_LINK)
{
    
// This presenting method should no longer be used
    
if (!@is_dir($phpbb_root_path $config['upload_path']))
    {
        
trigger_error($user->lang['PHYSICAL_DOWNLOAD_NOT_POSSIBLE']);
    }

    
redirect($phpbb_root_path $config['upload_path'] . '/' $attachment['physical_filename']);
    
file_gc();
}
else
{
    
send_file_to_browser($attachment$config['upload_path'], $display_cat);
    
file_gc();
}

See Also