Does Yii have any built-in functionality to force a "file/save as" dialog when clicking on a file URL?
Page 1 of 1
Force a 'file/save as'
#3
Posted 11 February 2010 - 06:20 AM
The simplest is to create a action to download this file.
I thing there are 'download files' classes at http://www.phpclasses.org/
I thing there are 'download files' classes at http://www.phpclasses.org/
#4
Posted 11 February 2010 - 11:06 AM
http://www.yiiframew...sendFile-detail in combination with a controller action
#7
Posted 12 February 2010 - 10:52 AM
Here is an example. Call it with yourdomain.tld/index.php?r=test/download
The file lies in the folder "download" under your document root.
Controller Test:
The file lies in the folder "download" under your document root.
Controller Test:
/**
* Download of the file
*/
public function actionDownload()
{
$file = '/download/document.pdf';
return Yii::app()->getRequest()->sendFile(basename($file), @file_get_contents(Yii::app()->getBasePath().'/..'.$file));
}
#8
Posted 12 February 2010 - 12:50 PM
No actually I want to create a link to the file itself, e.g. document.docx
In IE by default it opens up the document within the browser window. But I have seem some sites whereby you are always given the option to save the file even if it is a direct link to the file.
In IE by default it opens up the document within the browser window. But I have seem some sites whereby you are always given the option to save the file even if it is a direct link to the file.
#9
Posted 16 February 2010 - 09:31 AM
I don't suppose I could add .htaccess rules to do this? The only file types I am dealing with are .pdf and .doc
Share this topic:
Page 1 of 1

Help













