phpeveryday.com

The best tutorial of php, php framework, php strategies, object oriented oriented,


PHP File: Working Easy with File (Download)

Tag: file, download file   Category: PHP Classes
post: 04 Jan 2008 read: 691


PHP File Tutorial: In this post, we will learn how to build download page. You can make a file only can download, not render direct on browser. For example, you have test.txt file in www/test/file. When your user point to http://localhost/test/file/test.txt, browser will open direct. If you want ask browser to download it, you can follow this practice

Create a file named "download.php" within www/test/file. Enter following code:


 <?
 
 
 if($_GET['act']=='down'){
 
   include "class.file.php";
     $f = "C:\\AppServ\\www\\test\\file\\file.txt";
 	
     $file = new file($f);
     $file->Download();
 }
 
 ?>


Series this article:
PHP File: Working Easy with File (Read File)
PHP File: Working Easy with File (Create and Write)
PHP File: Working Easy with File (Delete File)
PHP File: Working Easy with File (Download)

| Give Your Opinion | Recommend
Share and Bookmark to: These icons link to social bookmarking sites where readers can share and discover new web pages.
digg del.icio.us technorati Ma.gnolia BlinkList

Recommended articles by other readers:
Web Services: How PHP Kiss VB.NET? (Part 1)
Chart: How to Build Cool Animation Real Time Chart
Joomla: Fast Road to Understand Component Programming
Email: Send Attachement Mail
mod_rewrite - Part 1: create your "fantasy" URL

What do You Think?
Your Name *:
Email *:
(Will not be published)
Website/URL:
Your Comment *:
* Required


615
posting