File "view_pdf.php"
Full Path: /home/analogde/www/Prog/MMM/Fusion/view_pdf.php
File size: 4.17 KB
MIME-type: text/x-php
Charset: utf-8
<?php
if (isset($_GET['path']))
{
// OK
/*
$pdfData = displayPdfFromUrl( $_GET['path'] );
$base64 = base64_encode($pdfData);
echo '<iframe src="data:application/pdf;base64,' .$base64 .' " width="100%" height="600"></iframe>';
*/
// OK
/*
header('Content-type: application/pdf');
header('Content-Disposition: inline; filename="' . $_GET['path'] . '"');
header('Content-Transfer-Encoding: binary');
header('Accept-Ranges: bytes');
readfile( $_GET['path'] );
*/
//zzz( $_GET['path'] );
// enregistre( $_GET['path'] );
office( $_GET['path'] );
}
// https://www.sanwebcorner.com/2016/07/load-pdfs-in-iframe-onclick-button.html
// https://www.geeksforgeeks.org/how-to-make-pdf-file-downloadable-in-html-link-using-php/
// https://www.stechies.com/display-pdfword-file-browser/
// https://www.codexworld.com/force-download-file-php/
//header("Content-type: application/x-msexcel");
//header("Content-type: application/octet-stream");
//header('Content-Disposition: inline; filename="'.basename($export_file).'"');
//readfile($export_file);
// mime listing https://gist.github.com/egulhan/efd2125ac2017b42d159 ++++
/*
if($online_viewer == 'google') {
echo '<iframe src="https://docs.google.com/viewer?embedded=true&hl=en&url=' . fm_enc($file_url) . '" frameborder="no" style="width:100%;min-height:460px"></iframe>';
} else if($online_viewer == 'microsoft') {
echo '<iframe src="https://view.officeapps.live.com/op/embed.aspx?src=' . fm_enc($file_url) . '" frameborder="no" style="width:100%;min-height:460px"></iframe>';
}
*/
$filename = "D:\wamp\www\myprojects\image1.pdf";
$filename = "https://analog-design.net/Fusion/dmPDF.pdf";
// Header
//content type header("Content-type: application/pdf"); header("Content-Length: " . filesize($filename));
// Send the file to the browser.
//readfile($filename);
//echo '<a href="$filename?pipo=$blase&typefile=$typeFile">$filename</a><br>';
$typeFile = "pdf";
echo "<a href=\"view_pdf.php?path=$filename&typefile=$typeFile\">Blabla</a>";
$filename = "https://analog-design.net/Fusion/word.docx";
echo "<a href=\"view_pdf.php?path=$filename&typefile=$typeFile\">Document Word</a>";
function displayPdfFromUrl($url) {
// Initialize cURL session
$ch = curl_init();
// Set cURL options
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Execute cURL request
$data = curl_exec($ch);
// Close cURL session
curl_close($ch);
// Return PDF file content
return $data;
}
$pdfData = displayPdfFromUrl($filename);
$base64 = base64_encode($pdfData);
//echo '<iframe src="data:application/pdf;base64,' .$base64 .' " width="100%" height="600"></iframe>';
echo "plouf";
function zzz($url)
{
echo "---->>>> " .$url;
// Use basename() function to return the base name of file
$file_name = basename($url);
// Use file_get_contents() function to get the file
// from url and use file_put_contents() function to
// save the file by using base name
if (file_put_contents($file_name, file_get_contents($url)))
{
echo "File downloaded successfully";
}
else
{
echo "File downloading failed.";
}
}
function enregistre($url)
{
//remoteURL = 'https://www.example.com/files/project.zip';
// Force download
header("Content-type: application/x-file-to-save");
header("Content-Disposition: attachment; filename=".basename($url));
ob_end_clean();
readfile($url);
}
function office($url)
{
//$file = 'path/to/document.docx';
echo $url;
//header('Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document');
//header('Content-Disposition: inline; filename="' . basename($url) . '"');
//header('Content-Length: ' . filesize($url));
//readfile($url);
echo '<iframe src="https://view.officeapps.live.com/op/embed.aspx?src=' . $url . '" frameborder="no" style="width:100%;min-height:460px"></iframe>';
}
?>