0

The issue at hand is that a blank file is downloaded, but the mysqldump file is created in the back end. How do I make the script wait for the dump to be done, and then start the download?

<?php

$filename = 'sqldump_' . date('YmdHis') . '.sql.gz';
$cmd = 'mysqldump --host=localhost --user=blah --password=blah database | gzip -c > ' . $filename;
passthru($cmd);

header('Content-Description: File Transfer');
header('Content-Type: application/x-gzip-compressed');
header("Cache-Control: no-cache, must-revalidate");
header("Expires: 0");
header('Content-Disposition: attachment; filename="' . basename($filename) . '"');
header('Content-Length: ' . filesize($filename));
header('Pragma: public');
header('Content-Disposition: attachment; filename="' . $filename . '"');

exit(0);
Alvin Bakker
  • 1,456
  • 21
  • 40

0 Answers0