This question already has an answer here:
Hey guys I just wanted to share this solution that I found for the error: Cannot modify header information - headers already sent.
Let's say one starts out with a code that contains headers like this:
<?php
header('Content-disposition: attachment; filename="video"');
header('Content-type: video/mp4');
$video = $_POST['$video'] ;
readfile("$video");
?>
For some reason PHP doesn't like this. To see how to fix this view answer below.
</div>
To fix this type of error you can add <? ob_start(); ?>
before the <?php
in your code and add <? ob_flush(); ?>
at the end of your code after ?> Like this:
<? ob_start(); ?>
<?php
header('Content-disposition: attachment; filename="video"');
header('Content-type: video/mp4');
$video = $_POST['$video'] ;
readfile("$video");
?>
<? ob_flush(); ?>
Hope this helps. This was a simple solution that I found and it works well for me and some others I know of.