-
☆ A M B ☆
- 24,524 Posts
I have had similar problems with a forced download, and found no solution within MODx. I had to "include" an external php file that forced the download then redirected back to the MODx page.
for download y create a snippet in the page like it and you dont need to say goodby modx for a mopment and can execute commands like insertion in database when download.
if ($_REQUEST[’action_send’]=="download"){
$securepath="THIS IS VERY IMPORTANT FOR PREVENT DOWNLOAD FOR EXAMPLE IN THE MANAGER FOLDER
$file=$_REQUEST[’url’];//the second part of the url
PUT HERE THE PATH TO THE ASSETS FOLDER OR UPPER"
$filename = $securepath.$file;
// required for IE, otherwise Content-disposition is ignored
if(ini_get(’zlib.output_compression’))
ini_set(’zlib.output_compression’, ’Off’);
// addition by Jorg Weske
$file_extension = strtolower(substr(strrchr($filename,"."),1));
if( $filename == "" )
{
exit;
} elseif ( ! file_exists( $filename ) )
{
exit;
};
switch( $file_extension )
{ //add your types of archives for download...
case "zip": $ctype="application/zip"; break;
default: $ctype="application/force-download";
}
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-Type: $ctype");
// change, added quotes to allow spaces in filenames, by Rajkumar Singh
header("Content-Disposition: attachment; filename=\"".basename($filename)."\";" );
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".filesize($filename));
readfile("$filename");
exit();
}
thx for help, work fine ^^.