Author Topic: Having troubles downloading my file with Header!!  (Read 569 times)

Offline Sim

  • Level 13
  • *
  • Posts: 104
  • Reputation: +1/-1
    • View Profile
    • Online RPG Creator
Having troubles downloading my file with Header!!
« on: March 24, 2011, 07:28:01 PM »
The following code works in FireFox, but When using IE, it will not download the file. Its always 0kb... Any ideas?

Code: [Select]
 $SEARCH = mysql_fetch_object($s_query);
        $fsize = filesize(cleanData($SEARCH->url));
    header("Pragma: public"); // required
    header("Expires: 0");
    header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
    header("Cache-Control: private",false); // required for certain browsers
    header("Content-Type: application/octet-stream");
    header("Content-Disposition: attachment; filename=" . str_replace(" ", "_",$SEARCH->title) . ".mp3;");
    header("Content-Transfer-Encoding: binary");
    header("Content-Length: ".$fsize);
    ob_clean();
    flush();
    readfile(cleanData($SEARCH->url));
« Last Edit: March 24, 2011, 07:30:33 PM by Sim »

Offline CygnusX

  • Level 24
  • *
  • Posts: 303
  • Reputation: +3/-2
    • View Profile
    • Lords of Midnight
Re: Having troubles downloading my file with Header!!
« Reply #1 on: March 24, 2011, 08:05:00 PM »
I've had this problem before too!  I wanted my link to open an excel file, but explorer gave me ye ole 0kb dl prompt.  I was finally able to solve it by tweaking the value of content-type: in the header.  What type of file are you trying to download?  It took me forever to find the right statement for excel (i'm guessing .mp3 based on the value of your Content-Disposition:).  
« Last Edit: March 24, 2011, 08:08:07 PM by CygnusX »

Offline Sim

  • Level 13
  • *
  • Posts: 104
  • Reputation: +1/-1
    • View Profile
    • Online RPG Creator
Re: Having troubles downloading my file with Header!!
« Reply #2 on: March 25, 2011, 02:26:21 PM »
I'm just trying to download mp3's. that will be the only file type.

Offline CygnusX

  • Level 24
  • *
  • Posts: 303
  • Reputation: +3/-2
    • View Profile
    • Lords of Midnight
Re: Having troubles downloading my file with Header!!
« Reply #3 on: March 25, 2011, 02:53:30 PM »
Then try replaceing:

header("Content-Type: application/octet-stream");

with

header('Content-Type: audio/mpeg'); // Audio MPEG (MP3,...)

 


SimplePortal 2.3.3 © 2008-2010, SimplePortal