/    Sign up×
Community /Pin to ProfileBookmark

I had some file DOWNLOADS working for a while but then went to an SSL connection. I’m stuck! When I enter my ‘sendStream()’ function it executes and the headers are sent but no download dialog appears in the brower. This holds true for both IE and FF.

I’m at a loss and looking for a set of headers that will send a CSV file from a https location to the browser.

Can anyone help?

Appreciate any ideas….

tony

[CODE]
function sendStream($str, $type, $filenameHint=’upsImport’) {

$browser = whichBrowser();
if( !$filenameHint )
$filenameHint = “YourFile”;

switch ($type) {
case “exe”: (($browser==’IE’ || $browser==’OPERA’)? ($ctype=”application/octetstream”):($ctype=”application/octet-stream”));
break;
case “pdf”: $ctype=”application/pdf”;
break;
case “zip”: $ctype=”application/zip”;
break;
case “doc”: $ctype=”application/msword”;
break;
case “xls”: $ctype=”application/vnd.ms-excel”;
break;
case “ppt”: $ctype=”application/vnd.ms-powerpoint”;
break;
case “gif”: $ctype=”image/gif”;
break;
case “png”: $ctype=”image/png”;
break;
case “jpe”: case “jpeg”:
case “jpg”: $ctype=”image/jpg”;
break;
case “csv”: $ctype=”text/text”;
break;
default: $ctype=”application/force-download”;
}

header(‘HTTP/1.1 200 OK’);
header(‘Date: ‘ . date(“D M j G:i:s T Y”));
header(‘Expires: Mon, 26 Jul 1997 05:00:00 GMT’);
header(‘Last-Modified: ‘ . date(“D M j G:i:s T Y”));
header(“Cache-Control: no-store, must-revalidate”); // TB
header(“Content-Type: application/force-download”); // changed to force download
header(“Content-Length: ” .strlen($str) );
header(“Content-Transfer-Encoding: Binary”); // added
header(‘Content-Disposition: attachment; filename=”‘.$filenameHint.’.’.$type.'”‘);

/*
header(“Pragma: public”);
header(“Pragma: no-cache”);
// header(‘Expires: ‘.gmdate(‘D, d M Y H:i:s’).’ GMT’);
header(‘Expires: Mon, 26 Jul 1997 05:00:00 GMT’);
// header(“Last-Modified: ” .gmdate(“D, d M Y H:i:s”) .” GMT”); // TB
header(“Cache-Control: must-revalidate, post-check=0, pre-check=0”);
header(“Cache-Control: no-store, must-revalidate”); // TB
// header(“Cache-Control: private”,false);
header(“Content-Type: $ctype”);
header(“Content-Transfer-Encoding: binary”);
header(‘Content-Disposition: attachment; filename=”‘.$filenameHint.’.’.$type.'”‘);
header(‘Content-Length: ‘.strlen($str));
*/

set_time_limit(0);
echo $str;
}
[/CODE]

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@netbuddyOct 26.2006 — Installing the upgrade to Lifestyle 1.0 by adding the plugin Girlfriend 0.1a will solve your head problem.

Or looking trough your code, not having used this myself, your saying that your went to HTTPS ?

whats this then? [code=php]header('HTTP/1.1 200 OK');[/code] or am I tree up the wrong barking?
Copy linkTweet thisAlerts:
@tbirnsethauthorOct 26.2006 — Doesn't seem to matter having an S or not in the header. I have no idea what Lifestyle is and not sure what it's supposed to do.

I've tried other header combinations as well and nothing seems to work from one of my sites (running apache 2.0 and PHP5) but does from another (running an older version of apache and PHP4).

tony
Copy linkTweet thisAlerts:
@netbuddyOct 26.2006 — One day you may find out...

HTTPS is not easy from the standpoint that the system is a secure server, what you may be doing may be contuary to the HTTPS protocol or you could be initalizing the request in the wrong fashion.

Usually where some form of "Security" is involved also involves the parting of hard cash for support and information, etc. Well in my experience when I tried to look at FTPS and HTTPS servers.

The programming side of things, I suggest taking a trip to the zend or php site for details on what you need to do to make your script work.

Maybe look at the php.ini settings, you may need to make some setting changes in them also.
×

Success!

Help @tbirnseth spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.23,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...