quel tipo di errore viene generato quando si sono già inviate delle informazioni al browser prima dell'header.[supersaibal]Originariamente inviato da donatobeltomo
Non ho ben capito il tuo suggerimento Sgurbat, il problema lo vorrei risolvere mettendo i files in un area non visibile al sito. Questa secondo me è la soluzione più sicura e più semplice, solo che non riesco a far funzionare gli script.
Ad esempio ho trovato in giro questo:
function download ($nome, $path)
{
$size=filesize ($path);
$fp=fopen ($path, "r");
$binary=fread ($fp, $size);
fclose ($fp);
$nome=stripslashes ($nome);
if (strpos($_SERVER['HTTP_USER_AGENT'],"Gecko")) {
$nome = strtolower ($nome);
$nome = str_replace("ä","a",$nome);
$nome = str_replace("ö","o",$nome);
}
header("Pragma: public");
header("Cache-control: private");
header("Expires: 0");
header("Content-type: application/RFC822");
header("Content-type: octet/stream\n");
header("Content-transfer-encoding: binary\n");
header("Content-Disposition: attachment; filename=".$nome."\n");
header("Content-Length:".$size);
#echo $binary;
exit();
}
download ("file.zip", "g:\a\file.zip");
Si dovrebbe poter scaricare qualsiasi tipo di file ma mi da il seguente errore:
Warning: Cannot modify header information - headers already sent by (output started at G:\Project\Web\root\index2.php:3) in G:\Project\Web\root\index2.php on line 19
Warning: Cannot modify header information - headers already sent by (output started at G:\Project\Web\root\index2.php:3) in G:\Project\Web\root\index2.php on line 20
Warning: Cannot modify header information - headers already sent by (output started at G:\Project\Web\root\index2.php:3) in G:\Project\Web\root\index2.php on line 21
Warning: Cannot modify header information - headers already sent by (output started at G:\Project\Web\root\index2.php:3) in G:\Project\Web\root\index2.php on line 22
Warning: Cannot modify header information - headers already sent by (output started at G:\Project\Web\root\index2.php:3) in G:\Project\Web\root\index2.php on line 23
Warning: Cannot modify header information - headers already sent by (output started at G:\Project\Web\root\index2.php:3) in G:\Project\Web\root\index2.php on line 24
Warning: Cannot modify header information - headers already sent by (output started at G:\Project\Web\root\index2.php:3) in G:\Project\Web\root\index2.php on line 25
Warning: Cannot modify header information - headers already sent by (output started at G:\Project\Web\root\index2.php:3) in G:\Project\Web\root\index2.php on line 26
In pratica non gradisce le istruzioni HEADER.
Da cosa può dipendere? [/supersaibal]
Controlla di non avere istruzioni echo/print o spazi bianchi prima dell'invio degli header.

Rispondi quotando