File "get_document01.php"

Full Path: /home/analogde/www/FormData/Fusion/Document to mysql/get_document01.php
File size: 2.52 KB
MIME-type: text/x-php
Charset: utf-8

<?php


$host = "analogdepat.mysql.db";
$user = "analogdepat";
$password = "Un92pac007";
$db = "analogdepat";

//Créer une connexion et sélectionner la base de données
$conn = new mysqli($host, $user, $password, $db);


// Vérifier la connexion
if($conn->connect_error)
{
    die("Erreur de connexion: " . $db->connect_error);
}

$id = 6;

echo "Zoulou";

//Récupérer l'image à partir du base de données
$res = $conn->query("SELECT content FROM db_document WHERE id = $id ");

$filename = "file.pdf";
$file = $filename;

if($res->num_rows > 0)
{
    while($row = $res->fetch_assoc() )
    {
        echo "OK";

        $ppp = $row['content'];

        file_put_contents('temp.pdf', $row['content']  );

        //header('Content-type: application/pdf'); 
        //header('Content-Disposition: inline; filename="' . $filename . '"'); 
        //header('Content-Transfer-Encoding: binary'); 
        //header('Accept-Ranges: bytes'); 
        //@readfile($file); 


        
       /* header('Content-Description: File Transfer');
        header('Content-Type: application/octet-stream');
        header('Content-Disposition: attachment; filename="' . basename($ppp) . '"');
        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($ppp));
        ob_clean();
        flush();
        //readfile($filepath);
        readfile($ppp);
        exit;*/

    }
}

/*
while ($myrowsel = mysql_fetch_array($res)) 
{

        echo "plouf";
        //header("Content-Type: application/pdf");
        //echo $myrowsel[content];
        //exit();

}
*/
 /*
if($res->num_rows > 0)
{

    $row = mysqli_fetch_assoc($res);
    $filename = 'file.pdf';
    header('Content-type: application/pdf');
    header('Content-Disposition: attachment; filename="' . $filename . '"');
    echo $row['PDF_File'];


    header("Content-Type: application/pdf");
     echo $myrowsel[AttachmentData];

        exit();
    //$img = $res->fetch_assoc();
    //header("Content-type: image/jpg"); 
    //echo $img['image']; 

}
else
{
    echo 'Image non trouvée...';
}
*/


/*
header('Content-type: application/pdf');
header("Cache-Control: no-cache");
header("Pragma: no-cache");
header("Content-Disposition: inline;filename=myfile.pdf'");
header("Content-length: ".strlen($pdf_contents));

echo $pdf_contents;
*/

?>