Solved

using include() on a compressed file

Posted on 2003-11-25
2
198 Views
Last Modified: 2013-11-18
I've got a file in a htaccess protected directory, that I want to have downloaded by people authenticated through a mysql database.

the problem that when I use include ("somedir/file.tar.gz"); the result is displayed binary rather than a download prompt.

any suggestions?

Alternately I've tried including a html file from the same directory, and have it redirect to the file in question. this ends up giving the expected login pop-up.. (I thought I could embed the authentication into the redirect link.. NOPE! heh)
0
Comment
Question by:kenfcamp
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 13

Accepted Solution

by:
lozloz earned 125 total points
ID: 9821298
hi,

you want to use header to tell the browser to download the file, then you need to use fopen to open the file and give it to the browser.. here's an example:

<?
$path = "somefile/file.tar.gz";
$thefile = file_get_contents($path);
header( "Content-type: application/x-gzip" );
header( "Content-Disposition: attachment; filename=yourchosenfilename.tar.gz" );
print $thefile;
?>

you can probably add some more information in the headers there if you want, such as

header("Content-Length: " . filesize($path));

best to look at the comments here though:

http://uk2.php.net/header

loz
0
 
LVL 14

Author Comment

by:kenfcamp
ID: 9821514
geez!

I was off by one string .. you nailed it..

Thanks !
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL several years ago, it seemed like now was a good time to update it for object-oriented PHP.  This article does that, replacing as much as possible the pr…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

624 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question