When trying to download a CSV export file, I'm getting an error in IE7 (but not in Firefox):
"Internet Explorer was not able to open this Internet Site. The requested site is either unavailable or cannot be found. Please try again later."

This seems to be a wider issue with cache control settings in the Drupal header:
http://drupal.org/node/18565

The error doesn't appear when the following IE7 option is checked: Tools - Internet Options, Advanced Tab, Security heading (almost all the way at the bottom), Do not save encrypted pages to disk.
Unfortunately, that setting is de-selected by default.

Based on the thread http://drupal.org/node/18565 , I've inserted the following line of code after the line 185:
drupal_set_header("Cache-Control: no-store, no-cache, must-revalidate");

This makes it work for IE, but might result in "unclean" code (I'm new to Drupal coding).

P.S.: I suppose the DOC export would have the same problem; but I didn't try.

Comments

dmitrig01’s picture

Status: Active » Fixed

Fixed.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.

rajesharma’s picture

Hi All ,

I have one working solution for this problem.

we dont have to make any drupal code changes here and there.

just work in the drupal way.

first create a new menu for download page.

like this...

$items[] = array(
'path' => 'addressbook/download',
'callback' => 'download_addressbook',
'access' => user_access('manage addressbook'),
'type' => MENU_CALLBACK,
);

after that create your function which will gather the download data and store it in a $_SESSION variable
function yourfunction()
{
$_SESSION['filearray']['data'] = $csvString; //your data
$_SESSION['filearray']['name'] = "address_book.csv"; //'filename for download'
$_SESSION['filearray']['mime'] = "text/csv"; /'mime type'
$_SESSION['filearray']['size'] = strlen($csvString); //length of the data

after storing data in session just redirct to that page

header('location:?addressbook/download');
die();
}

function download_addressbook()
{
if(isset($_SESSION['filearray']['data']) && trim($_SESSION['filearray']['data'])!="")
{
force_download($_SESSION['filearray']['data'],$_SESSION['filearray']['name'],$_SESSION['filearray']['mime'],$_SESSION['filearray']['size']);
}
else
{
header('location:?q=addressbook/view');
die();
}
}

function force_download ($data, $name, $mimetype='', $filesize=false) {
// File size not set?
if ($filesize == false OR !is_numeric($filesize)) {
$filesize = strlen($data);
}

// Mimetype not set?
if (empty($mimetype)) {
$mimetype = 'application/octet-stream';
}

// Make sure there's not anything else left
// ob_clean_all();

// Start sending headers
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-Transfer-Encoding: binary");
header("Content-Type: " . $mimetype);
header("Content-Length: " . $filesize);
header("Content-Disposition: attachment; filename=\"" . $name . "\";" );

// Send data
echo $data;
die();
}

thanks regards
Rajesh

xurizaemon’s picture

StatusFileSize
new790 bytes

This was fixed in May, but it seems the update hasn't been released in a stable version yet?

I think this fix should do it (seems to work for me to prevent issues with download on IE6/IE7)

steingard’s picture

I applied this patch and I'm still having trouble on this issue.

The patch did return with 1 error out of 2 HUNKS...?

It produced a views_bonus_export.module.rej file that states

***************
*** 182,187 ****
      }
      $output .= implode(',', $values) . "\r\n";
    }
    drupal_set_header('Content-Type: text/x-comma-separated-values');
    drupal_set_header('Content-Disposition: attachment; filename="view-'. $view->name .'.csv"');
    print $output;
--- 182,188 ----
      }
      $output .= implode(',', $values) . "\r\n";
    }
+   drupal_set_header('Cache-Control: max-age=60, must-revalidate');
    drupal_set_header('Content-Type: text/x-comma-separated-values');
    drupal_set_header('Content-Disposition: attachment; filename="view-'. $view->name .'.csv"');
    print $output;
xurizaemon’s picture

StatusFileSize
new759 bytes

@steingard - here's the same patch for 5.x-1.2alpha2 - please try this instead and report back if it works?

steingard’s picture

Status: Closed (fixed) » Active

The patch file worked nicely, thanks!

Something that is important to remember... is to setup the Views Export permissions properly (in addition to the View's perms).

steingard’s picture

Status: Active » Needs review

This patch needs to find its way into the contributed module.

pomliane’s picture

Status: Needs review » Closed (won't fix)

This version of Views Bonus Pack is not supported anymore. The issue is closed for this reason.
Please upgrade to a supported version and feel free to reopen the issue on the new version if applicable.

This issue has been automagically closed by a script.