Mauro Casula a écrit :
Hi all,
I have an action that make a mysql database backup in this way:
public function backupDatabaseAction()
{
$db = Zend::registry('db');
$view = Zend::registry('view');
$config = Zend::registry('config');
$session = Zend::registry('session');
$view->title = $config->site->title." - Modifica di una casa";
$ctr = new CaseVacanzaDataController($db, $session);
$view->actionTemplate = 'main.php';
$view->header = $view->render('header.php');
system($config->bin_path."\export_db.bat", $ret);
$view->menu = $view->render('menu_amministrazione.php');
$view->body =
$view->render('admin_backup_database.php');
$view->footer = $view->render('footer.php');
echo $view->render('main.php');
}
the export_db.bat script write a Sql backup file in a specific directory..
What I have to do for return this file directly with the download popup and
so delete it..?
Thankyou in advance for the answers..
Regards.
Mauro Casula
Hello,
this could help you maybe :
basically you could do that
$str = file_get_contents($file);
header('Content-Disposition: attachment;
filename="downloaded.pdf"');
header('Content-type: application/pdf');
echo $str;
the example is for a pdf file, in your example, yous hould change
Content-type (look for it in header doc) Content-Disposition: attachment
makes the download window opens in order to save it or display it on the
client side.
But I guess, a "zfer" way would be to use the response object, maybe
like this :
|$this->getResponse()
->setHeader('Content-Type', 'text/plain')
||->setHeader('|Content-Disposition|', '|attachment; filename="bkp.sql"'|') |
| ->appendBody(|$str|);
Hope this could help you, though I didn't test it. At least it works for me
with pdf files.
fred
|