1
astrix
XoopsZipDownloader
  • 2004/8/25 2:02

  • astrix

  • Just popping in

  • Posts: 30

  • Since: 2004/8/16


The XoopsZipDownloader class seems to work well. Only one problem, when I call the download method (ie $mydownloader->download('files.zip')), it doesn't seem to send a content-length: header to the browser, so the browser can't determine how large the file is so the status bar is blank. Is there a way to remedy this?

2
astrix
Re: XoopsZipDownloader
  • 2004/8/25 2:23

  • astrix

  • Just popping in

  • Posts: 30

  • Since: 2004/8/16


NM, I found a solution, for anyone who wants to know:

edit /class/downloader.php
in class XoopsDownloader
in function _header

I just added:

header('Content-length: '.filesize($filename));

after header('Content-Type: '.$this->mimetype);

3
astrix
Re: XoopsZipDownloader
  • 2004/8/25 2:46

  • astrix

  • Just popping in

  • Posts: 30

  • Since: 2004/8/16


Well, that doesn't seem to work very well for multiple files in zip :(

4
astrix
Re: XoopsZipDownloader
  • 2004/8/25 3:09

  • astrix

  • Just popping in

  • Posts: 30

  • Since: 2004/8/16


Ok, the solution (For real now):

in file zipdownloader.php I just replaced the contents of function "download" with this:

$this->_header($name.$this->ext);
$file_data = $this->archiver->file();
header('Content-length: '.strlen($file_data));
echo $file_data;

that works well

5
bingomanatee
Re: XoopsZipDownloader

I have applied your patch and I still get the message (from the OS after downloading the ZIP:)

"The archive is corrupted and cannot be read."

Any suggestions?

Thanks... Dave

6
m0nty
Re: XoopsZipDownloader
  • 2006/3/14 0:04

  • m0nty

  • XOOPS is my life!

  • Posts: 3337

  • Since: 2003/10/24


you're on the right track, but you maybe unaware that IE has a major bug that you can't get around easily..

you'll find the method above should work fine with firefox and other browsers..

I just spent over 14hrs constantly trying to solve this same issue in the upcoming wf-downloads release, and it wasn't easy to find a solution that worked on all browsers especially IE.

here's a snippet of the headers that i found worked fine after much experimentation na dhair pulling..

you should be able to adjust this to your hack or whatever you are trying to achieve.

if(ini_get('zlib.output_compression'))
ini_set('zlib.output_compression''Off'); // must do for IE

header("Pragma: public"); // you must make this public for IE
header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); // also for IE
header("Cache-Control: private",false);
header("Content-Transfer-Encoding: binary");
header("Content-Type: " $mimeType);
header("Content-Disposition: attachment; filename=" $file_name);

$fp fopen($filePath"rb");
fpassthru($fp);
exit();


i've adjusted it somewhat for your needs and removed some of the wf-d code from it. but you should be able to make it work from that.

$mimeType needs to be 'x-zip compressed' for zip files

$filePath needs to be defined also, this should be the absolute path to the file, not the URL, so you can use XOOPS_ROOT_PATH as a start.

hope this helps..

7
m0nty
Re: XoopsZipDownloader
  • 2006/3/14 0:06

  • m0nty

  • XOOPS is my life!

  • Posts: 3337

  • Since: 2003/10/24


forgot to mention, also. do not add Content-Length to the header as that will make the files corrupt on download aswell..

IE is 1 big headache..

Login

Who's Online

343 user(s) are online (294 user(s) are browsing Support Forums)


Members: 0


Guests: 343


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits