CodeCharge Studio
search Register Login  

Visual Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 [RESOLVED] File download, original filename...

Print topic Send  topic

Author Message
songohan

Posts: 89
Posted: 07/02/2009, 3:57 PM

Thanks to Tangels code from 2005 (http://forums.yessoftware.com/posts.php?post_id=56563) I resolved how to keep timestamp in filename on server and still offer file with original name to user for download.
I added following code to After Initialise event on page where where I have link to file. Link points to same page and adds "filename" parameter to URL.
Adding this code to Before Show also works but if Cancel button is pressed in "Save file" dialog box browser gets stuck for some time and content of file is printed to page (Firefox).

  
if (CCGetFromGet('file') != ""){  
	$dir ="user_files/";   
	$file_name = CCGetFromGet('file');  
	$file = ($dir.$file_name);  
	$original_filename = CCGetOriginalFileName($file_name);  
  
	header("Content-Length: " . filesize($file));    
	header("Content-Type: application/octet-stream");    
	header("Content-Disposition: attachment; filename=\"$original_filename\"");    
	header("Content-Transfer-Encoding: binary");    
	readfile($file);   
}  
  
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Internet Database

Visually create Web enabled database applications in minutes.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.