par
Drum » 23 juil. 2010, 22:10
Bonsoir,
une page Html propose de traiter les tables a l ''exportation'', listees dans un tableau Html.
<td>
<a href="./exportation/download.php?file='.$tab[$i+1].'.csv"> <img border="0" src="../image/table.png" width="23" height="20" alt="'.$tab[$i+1].'.csv" /></a>
</td>
le lien au survol donne :
http:// 127.0.0.1/exportation/download.php?file=mailing.csv
le source download.php
<?php
$file = $_GET["file"];
download($file);
function download($file, $name = false, $type = false, $down = true) {
if(!file_exists($file)){
print "error";
exit;
}
if(!$name) $name = basename($file);
if($down) $type = "application/force-download";
else if(!$type) $type = "application/download";
$disp = $down ? "attachment" : "inline";
#header ("HTTP/1.0 204 No Content" );
header("Content-disposition: ".$disp."; filename=$name");
header("Content-length: ".filesize($file));
header("Content-type: ".$type);
header("Connection: close");
header("Expires: 0");
readfile($file);
exit;
}
?>
j espere donner les elements attendus ?
Merci pour les reponses a cette ''enigme'' !
a++