Monday 27 February 2017

php - Cannot modify header information - headers already sent easy solution





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:




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.


Answer



To fix this type of error you can add before the in your code and add at the end of your code after ?>

Like this:




header('Content-disposition: attachment; filename="video"');
header('Content-type: video/mp4');
$video = $_POST['$video'] ;
readfile("$video");
?>




Hope this helps. This was a simple solution that I found and it works well for me and some others I know of.


No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...