Hello! I dump the database and want to give it out right away to download the file. On the server, the file is saved perfectly, all as it should. But at the download I get a file that starts with the html code of the page from which I am downloading, and after this code is already a dump. Help me figure out where this code comes from. Here is the file issue code:

if ($stream) { header('Content-Disposition: attachment; filename='.$dump_name.$ofdot); if($gzip) header('Content-type: application/x-gzip'); else header('Content-type: text/plain'); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0,pre-check=0"); header("Pragma: public"); echo $data; } 
  • Make the code as it should be and give more examples. From the question it is clear that the problem is not in this piece of code ... - GrayHoax
  • If you are given an exhaustive answer, mark it as correct (a daw opposite the selected answer). - Nicolas Chabanovsky

1 answer 1

You probably have html at the beginning of the php-file, then the return code of your dump. Put the PHP code in the beginning of the file and, of course, after returning the dump, interrupt the execution of the skipt - exit();

  • well, I myself for some reason did not think of the code at the beginning :) thanks, everything is in its place! - Dzedzik