I hate the header() function...
I'm trying to backup some mySQL tables to a file, then push the file down through the browser, but it's not working as expected.
When I use this code, I get a blank file, but if I use header("Location: db/$filename"); it displays the mysqldump output. Great, but I want to send a file, not have to file/save in IE...
Any ideas?
(by the way, I know this isn't exactly the most secure way to do this, but I figure I'd throw in some random filenames and stuff to fend off the 1337 h4xx0rz for 10 minutes while the file's being sent.. I call it "Security through random filenames".
$seed=mt_rand();
$string=md5($seed);
$getfile=substr("$string", 5, 8);
$filename=$getfile.".sql";
exec("mysqldump --opt -h$dbhost -u$dbuser -p$dbpass $dbname > db/$filename");
header("Content-type: application/x-download");
header("Content-Disposition: attachment; filename=db/$filename");
When I use this code, I get a blank file, but if I use header("Location: db/$filename"); it displays the mysqldump output. Great, but I want to send a file, not have to file/save in IE...
Any ideas?
(by the way, I know this isn't exactly the most secure way to do this, but I figure I'd throw in some random filenames and stuff to fend off the 1337 h4xx0rz for 10 minutes while the file's being sent.. I call it "Security through random filenames".
$seed=mt_rand();
$string=md5($seed);
$getfile=substr("$string", 5, 8);
$filename=$getfile.".sql";
exec("mysqldump --opt -h$dbhost -u$dbuser -p$dbpass $dbname > db/$filename");
header("Content-type: application/x-download");
header("Content-Disposition: attachment; filename=db/$filename");
