1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
|
<?php session_start();
include ("fonction/fonction.bdd.php");
connexion_mysql();
//echo "une erreur";
if (isset($_SESSION["id_uc"]) && isset($_GET["type"]) && isset($_GET["file"]))
{
//echo "une erreur2";
if($_GET["type"] == 'commun')
{
//echo "une erreur3";
$res=mysql_query("select CONCAT(chemin_dc, fichier_dc) as path from document_commun where id_dc='".$_GET["file"]."';") or die(mysql_error());
//echo "select CONCAT(chemin_dc, fichier_dc) as path from document_commun where id_dc='".$_GET["file"]."';";
}
elseif($_GET["type"] == 'individuel')
{
// echo "une erreur4";
$res=mysql_query("select CONCAT(chemin_di, fichier_di) as path from document_individuel where id_di='".$_GET["file"]."';") or die(mysql_error());
}
else
{
echo "une erreur5";
}
if(mysql_num_rows($res)!=0){
$row=mysql_fetch_object($res);
header("Content-type: application/octet-stream; name=".basename($row->path)."");
header("Content-Transfer-Encoding: Binary");
header("Content-Length: ".filesize($row->path));
header("Content-Disposition: attachment; filename=".basename($row->path));
readfile($row->path);
}
} else {
echo "une erreur";
// header("Location: http://espace-cb.xxxx.com/...");
}
?> |
Partager