Modified File-Action
http://support.microsoft.com/kb/316431
http://support.microsoft.com/kb/815313
When you attempt to open or download a Microsoft Office document (.doc file, .xls file, .ppt file, and so on) from a secure Web site in Internet Explorer, you may receive one of the following error messages, even though the document is available and downloaded from the server:
Internet Explorer cannot download file from server.
Internet Explorer was not able to open this Internet site. The requested site is either unavailable or cannot be found. Please try again later.
-or-
The page cannot be displayed.
The page you are looking for is currently unavailable. The Web site might be experiencing technical difficulties, or you may need to adjust your browser settings.
Cannot find server or DNS Error
-or-
Office Application Name cannot open the file.
The problem occurs if the server is using Secure Sockets Layer (SSL) and has added one or both of the following HTTP headers to the response message:
Pragma: no-cache Cache-control: no-cache,max-age=0,must-revalidate
- What are you suggesting here Hillar? That IE has a bug or that Wikka has a bug? Or both? What is your solution (and will it work with all browsers)? --JavaWoman
- I was experiencing the IE download bug in our educational wiki. Students were not able to download files using IE, there were no problems with using FireFox. Im not sure about other browsers. I guess it's an IE specific problem. Hillar's patch fixed this problem nicely, thanks dude ;) -- JeroenJansen
<?php
// upload path
if ($this->config['upload_path'] == '')
$this->config['upload_path'] = 'files';
$upload_path = $this->config['upload_path'].'/'.$this->GetPageTag();
if (! is_dir($upload_path))
mkdir_r($upload_path);
// do the action
switch ($_REQUEST['action']) {
case 'download':
$_REQUEST['file'] = basename(urldecode($_REQUEST['file']));
if ($this->HasAccess('read')) {
$path = "{$upload_path}/{$_REQUEST['file']}";
$filename = basename($path);
// Examine Suffix
if (preg_match("/.*\.(\w+)$/i",$filename,$res))
$suffix=$res[1];
// Search MIME Type
if (!$suffix || $suffix=="" || !$this->config['mime_types']
|| !$mimes=implode("\n",file($this->config['mime_types'])))
$content_type="application/force-download";
else {
if (preg_match("/([A-Za-z.\/-]*).*$suffix/i",$mimes,$result))
$content_type=$result[1];
else
$content_type="application/force-download";
}
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: public");
header("Content-Description: File Transfer");
Header("Content-Type: ".$content_type);
//Force the download
Header("Content-Disposition: attachment; filename=".$filename);
header("Content-Transfer-Encoding: binary");
Header("Content-Length: ".filesize($path));
// Header("Connection: close");
@readfile($path);
exit();
}
case 'delete':
if ($this->HasAccess('write')) {
// if ($this->IsAdmin()) {
@unlink("{$upload_path}/{$_REQUEST['file']}");
}
print $this->redirect($this->Href());
}
?>
// upload path
if ($this->config['upload_path'] == '')
$this->config['upload_path'] = 'files';
$upload_path = $this->config['upload_path'].'/'.$this->GetPageTag();
if (! is_dir($upload_path))
mkdir_r($upload_path);
// do the action
switch ($_REQUEST['action']) {
case 'download':
$_REQUEST['file'] = basename(urldecode($_REQUEST['file']));
if ($this->HasAccess('read')) {
$path = "{$upload_path}/{$_REQUEST['file']}";
$filename = basename($path);
// Examine Suffix
if (preg_match("/.*\.(\w+)$/i",$filename,$res))
$suffix=$res[1];
// Search MIME Type
if (!$suffix || $suffix=="" || !$this->config['mime_types']
|| !$mimes=implode("\n",file($this->config['mime_types'])))
$content_type="application/force-download";
else {
if (preg_match("/([A-Za-z.\/-]*).*$suffix/i",$mimes,$result))
$content_type=$result[1];
else
$content_type="application/force-download";
}
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: public");
header("Content-Description: File Transfer");
Header("Content-Type: ".$content_type);
//Force the download
Header("Content-Disposition: attachment; filename=".$filename);
header("Content-Transfer-Encoding: binary");
Header("Content-Length: ".filesize($path));
// Header("Connection: close");
@readfile($path);
exit();
}
case 'delete':
if ($this->HasAccess('write')) {
// if ($this->IsAdmin()) {
@unlink("{$upload_path}/{$_REQUEST['file']}");
}
print $this->redirect($this->Href());
}
?>
CategoryUserContributions