GIDForums  

Go Back   GIDForums > Computer Programming Forums > MySQL / PHP Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 12-Apr-2003, 22:06
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,371
JdS will become famous soon enough
Unhappy

How to offer .tar.gz file downloads?


The problem: I am trying to write a PHP script that allows me to easily manage all my MySQL databases and tables from one place.

Unlike phpmyadmin, it will 'dump' (backup) the databases, tar it and then finish it off with a slight dose of 'gzip'. So far everything works perfectly. Now I want to be able to download the gzipped files from a list on the page, the script contains the following header statements:
PHP Code:

<?php
$filename = 'gzipped.tar.gz';
$fpath = '/path/to/'.$filename;

header( 'Content-type: application/x-gzip' );
header( 'Content-Disposition: attachment; filename="'.$filename.'"' );            
header( 'Content-transfer-encoding: binary' ); // Required? Not sure..
header( 'Content-Length: '.filesize($fpath) ); // Required? Not sure...
readfile( $fpath );
exit;
?>


I have to do it this way since the files are located above the WWW root.

With the version of Microsoft's Internet Explorer that I use (v.6), it adds a number everytime I download the file. e.g.

sitedb[1].tar.gz

The item in bold is what MSIE adds to the downloaded file name. The script/download works beautifully with Mozilla or Opera, so I am a little confused...

I must admit that this is the first time I am attempting something like this; so all I have to-date, is a few lines of code I gathered from elsewhere.

I hope someday, someone reading this, will be able to help me out.
  #2  
Old 12-Apr-2003, 22:56
jrobbio's Avatar
jrobbio jrobbio is offline
Regular Member
 
Join Date: Jan 2003
Location: Loughborough, England
Posts: 840
jrobbio will become famous soon enough
I'm probably off the beaten track here, but check out this and see if past half way down is relevant at all.http://store.sun.com/docs/sunstore_f...e_buying.jhtml

Internet exporer does the same with cookies too.

I had a fairly long search, but to no avail is there somewhere that I could test it out on my IE6 and see if I get similar results.
  #3  
Old 12-Apr-2003, 23:10
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,371
JdS will become famous soon enough
I appreciate the help Rob but I don't think that was it. This is about manipulating the headers being sent out by the script - wrong headers, wrong results.

The page I am testing is LIVE behind a passworded area, now containing live backups, so I cannot offer a test link right now - not to mention that it wouldn't be too difficult to cut N paste the code above and test it yourself trying to download a dummy .tar.gz file on your server.

For all the webmasters who don't have shell access (Telnet/SSH) to their server, a script like this is precious...
  #4  
Old 12-Apr-2003, 23:30
jrobbio's Avatar
jrobbio jrobbio is offline
Regular Member
 
Join Date: Jan 2003
Location: Loughborough, England
Posts: 840
jrobbio will become famous soon enough
  #5  
Old 13-Apr-2003, 14:10
Garth Farley Garth Farley is offline
Awaiting Email Confirmation
 
Join Date: May 2002
Location: Ireland
Posts: 638
Garth Farley is a jewel in the roughGarth Farley is a jewel in the roughGarth Farley is a jewel in the rough
I think that that is just a silly thing that IE does, due to the way it handles it's cache. Mabye send the nocache header too?

This is a good tool to check headers, courtesy of the good man Delorie www.delorie.com

GF
  #6  
Old 14-Apr-2003, 06:18
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,371
JdS will become famous soon enough
I added the following headers and still no change infact files are now corrupt when downloaded.
PHP Code:

<?php

header ('Pragma: no-cache');
header ('Cache-Control: private, max-age=0, no-cache');
header ('Date: '.gmdate('D, d M Y H:i:s').' GMT');

?>


Any other ideas?
  #7  
Old 14-Sep-2003, 18:30
jrobbio's Avatar
jrobbio jrobbio is offline
Regular Member
 
Join Date: Jan 2003
Location: Loughborough, England
Posts: 840
jrobbio will become famous soon enough
Did you ever fix this?
 
 

Recent GIDBlogProblems with the Navy (Chiefs) by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Reading from file jmenendezr C++ Forum 2 26-Feb-2006 17:00
Limited file size.... lament Apache Web Server Forum 2 31-May-2004 14:35
Before posting a web hosting offer or ad - PLEASE READ admin Web Hosting Advertisements & Offers 0 19-Sep-2003 11:41
How to search a huge text file for data? JdS MySQL / PHP Forum 7 27-May-2003 10:27
How Do i get php to find out the file type of a file for me? viperman95833 MySQL / PHP Forum 2 08-Mar-2003 10:48

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 22:07.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.