
March 21st, 2003, 08:01 PM
|
|
Contributing User
|
|
Join Date: Oct 2002
Location: Washington, DC
Posts: 317
Time spent in forums: 2 m 3 sec
Reputation Power: 7
|
|
Quote:
would like to know if anyone could tell me how i can implement this to download files, rather than displaying pages. |
Read the file in using the file system functions and them just stream the download to the user.
PHP Code:
if ( $user_logged )
{
$file = 'dir/the_file.zip';
$fp = fopen( $file, 'r' );
$file_data = fread( $fp, filesize( $file ) );
fclose( $fp );
clearstatcache();
$filename = 'name_of_file_you_want_it_to_be.zip'; // needs correct extension
header( "Content-type: application/octet-stream" );
header( "Content-disposition: attachment; filename=$filename" );
echo( $file_data );
}
I didn't read the article, but I think this is what you are looking for...
__________________
~ Joe Penn
We work for free to help make this a valuable resource on the internet. Do you appreciate the help - did we provide help that will help you prosper and help that has contributed to sharpening your current skill set?
Show your appreciation and purchase something from our Amazon Wishlist's - it's simple and a great way to say thank you.
|