Hi i want to give the rights to user to take the database backup.but its store in the server only .
i want, if user click on backup button its ask for save target and the database as per user define path.
iam using the following code but its not working
$backupFile = $db_name."_".date( "Y-m-d-H-i-s" ).".gz";
Header("Content-type: application/octet-stream");
Header("Content-Disposition: attachment; filename=$backupFile");
Thanks
Manoj
mysql backup through php ask for save as
Moderator: General Moderators
-
manojsemwal1
- Forum Contributor
- Posts: 217
- Joined: Mon Jun 29, 2009 4:13 am
- Location: India
-
litebearer
- Forum Contributor
- Posts: 194
- Joined: Sat Mar 27, 2004 5:54 am
Re: mysql backup through php ask for save as
if the file already exists, simply create a link to it. No need for headers
-
manojsemwal1
- Forum Contributor
- Posts: 217
- Joined: Mon Jun 29, 2009 4:13 am
- Location: India
Re: mysql backup through php ask for save as
Thanks for ur quick reply.....
iam using the following code to create the file..... but at the same time how can i use save target as .sql format............
$handle = fopen('db-backup-'.date( "Y-m-d-H-i-s" ).'.sql','w+');
fwrite($handle,$return);
fclose($handle);
Thanks
iam using the following code to create the file..... but at the same time how can i use save target as .sql format............
$handle = fopen('db-backup-'.date( "Y-m-d-H-i-s" ).'.sql','w+');
fwrite($handle,$return);
fclose($handle);
Thanks
-
litebearer
- Forum Contributor
- Posts: 194
- Joined: Sat Mar 27, 2004 5:54 am
-
manojsemwal1
- Forum Contributor
- Posts: 217
- Joined: Mon Jun 29, 2009 4:13 am
- Location: India
Re: mysql backup through php ask for save as
thanks once again
I had read that earlier but not got a solution.................
Pl give another one..............
Thanks.
I had read that earlier but not got a solution.................
Pl give another one..............
Thanks.
-
manojsemwal1
- Forum Contributor
- Posts: 217
- Joined: Mon Jun 29, 2009 4:13 am
- Location: India
Re: mysql backup through php ask for save as
Thanks
I have found the solution ...........its work for me.........
if any body want to do this pl use it..........
insert the correct file name and path.........
$fullPath=$backup_path.$backupFile;
//echo $fullPath;
// File Exists?
if(file_exists($fullPath) )
{
echo $fullPath;
$fsize = filesize($fullPath);
$path_parts = pathinfo($fullPath);
$ext = strtolower($path_parts["extension"]);
$ctype="application/zip";
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");
header("Content-Disposition: attachment; filename=\"".basename($fullPath)."\";" );
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".$fsize);
ob_clean();
flush();
readfile( $fullPath );
}
Thanks
Manoj Semwal
I have found the solution ...........its work for me.........
if any body want to do this pl use it..........
insert the correct file name and path.........
$fullPath=$backup_path.$backupFile;
//echo $fullPath;
// File Exists?
if(file_exists($fullPath) )
{
echo $fullPath;
$fsize = filesize($fullPath);
$path_parts = pathinfo($fullPath);
$ext = strtolower($path_parts["extension"]);
$ctype="application/zip";
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");
header("Content-Disposition: attachment; filename=\"".basename($fullPath)."\";" );
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".$fsize);
ob_clean();
flush();
readfile( $fullPath );
}
Thanks
Manoj Semwal