Jump to content

[Resolved] Problemswith Download

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
2 replies to this topic

#1
marting

marting

    Newbie

  • Members
  • Pip
  • 3 posts
Hi,

I seem to have an issue with downloading files!
If I configure the files to 'Download as link' all works fine, But I would like to use them as 'Download' and not as link.

Whatever I do, it saves/opens a file of 0 bytes.

I did some debugging myself, but cannot figure it out.

It does seem to do the curl bit, and I can see $fsize is filled, $file is ok, and $download as well..
The only thing that doesn't seem to return anything is the 'get_ini' blah blah statement..

I also tried to comment out all the header bits and use just a simple 3 line header sequence (which I used on the previous site, before I start using Joomla);

header("Content-Type: application/save");
header("Content-Disposition: attachment; filename=\"".basename($file)."\"");
readfile($file);

What ever I do, change paths on the files etc etc It doesn't work..

Help me pleasz..

//EDIT

I just noted that the allow_url_fopen is set to Off by my provider.. I did try to set it on in my .htaccess, but doesn't seem to make a difference.. could that be the cause, and ifso, is there a solution?
Thanks

#2
marting

marting

    Newbie

  • Members
  • Pip
  • 3 posts
Ok, I've managed to tweak it and get it to work..

This is what I added to download.php

                     

[I]$file=$_SERVER['DOCUMENT_ROOT']."$file";[/I]

header("Accept-Ranges: bytes");

readfile($file) or die ("Error");

This seemed to work for me.. but I do like to know why I needed to do this..

#3
TkTech

TkTech

    The Crazy One

  • Moderators
  • 1,396 posts
allow_url_fopen being off would prevent readfile() (which uses the base fopen function ) from opening files as a url. Somehow the interpreter is seeing your path as a link. The code you added gives a plain path to the file, and the server knows its local, and will allow a pipe to open.