Wiki source for FilesActionHillar

Show raw source

====Modified File-Action====

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.
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
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
~~~&**Only** with FireFox? What about other browsers? Mozilla, Opera, Amaya, Netscape, Lynx... I'm still not clear whether we're talking about a bug in IE or a bug in Wikka or both. --JavaWoman


// 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))
// 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))
// Search MIME Type
if (!$suffix || $suffix=="" || !$this->config['mime_types']
|| !$mimes=implode("\n",file($this->config['mime_types'])))
else {
if (preg_match("/([A-Za-z.\/-]*).*$suffix/i",$mimes,$result))
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");
case 'delete':
if ($this->HasAccess('write')) {
// if ($this->IsAdmin()) {
print $this->redirect($this->Href());

Valid XHTML :: Valid CSS: :: Powered by WikkaWiki