Cannot modify header information - headers already sent by

Répondre


Cette question est un moyen d’empêcher des soumissions automatisées de formulaires par des robots.
Smileys
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow: :| :mrgreen: =D> #-o =P~ :^o :non: :priere: 8-|
Voir plus de smileys
  Revue du sujet
 

  Étendre la vue Revue du sujet : Cannot modify header information - headers already sent by

Re: Cannot modify header information - headers already sent

par shaloine » 19 févr. 2013, 13:08

probleme resolu

Re: Cannot modify header information - headers already sent

par shaloine » 19 févr. 2013, 12:32

ptite precision, je ne sais pas si cela a une importance
mais dans le dossier un se trouve monfichier.pdf

il y a un fichier .htaccess avec ces lignes

Order allow,deny
Deny from all
Satisfy All

Cannot modify header information - headers already sent by

par shaloine » 19 févr. 2013, 12:08

Bonjour,
pour commencer je tien a dire que je ne connais rien au php, du coup j'essaie un peu comme je peu

voici mon probleme, j'ai un site sur lequel j'essai de securiser l'acces à certains document

j'utilise le tuto de cette adresse:
http://www.siteduzero.com/informatique/ ... s-fichiers

j'essaie deja de le mettre sur une page simple afin de voir si cela marche mais on me renvoi

Warning: Cannot modify header information - headers already sent by (output started at /htdocs/public/www/img/telechargement/fr/formation/essai.php:1) in /htdocs/public/www/maPage/essai.php on line 7

voici le code
<?php
function telecharger_fichier($fichier)
{
 $chemin = 'fichier/' . $fichier;
 if(file_exists($chemin))
 {
  header('Content-Description: File Transfer');
  header('Content-Type: application/octet-stream');
  header('Content-Disposition: attachment; filename=' . basename($chemin));
  header('Content-Transfer-Encoding: binary');
  header('Expires: 0');
  header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
  header('Pragma: public');
  header('Content-Length: ' . filesize($chemin));
  readfile($chemin);
  exit; 
 }
 else
  require('erreur.php');
}
telecharger_fichier('monFichier.pdf');
?>
c'est tout ce qu'il y'a dans mon fichier
le warning s'affiche pout chacune des ligne header() (je ne les vous pas toutes mises histoire de pas saturer)

merci d'avance pour votre aide