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 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
|
<?
/*
Fonction pour enregistrer un fichier sur le disque dur client
trouvée sur le manual de php, date du 31/01/11
*/
function downloadFile( $fullPath ){
// Must be fresh start
if( headers_sent() )
die('Headers Sent');
// Required for some browsers
if(ini_get('zlib.output_compression'))
ini_set('zlib.output_compression', 'Off');
// File Exists?
if( file_exists($fullPath) ){
// Parse Info / Get Extension
$fsize = filesize($fullPath);
$path_parts = pathinfo($fullPath);
$ext = strtolower($path_parts["extension"]);
// Determine Content Type
switch ($ext) {
case "png": $ctype="image/png"; break;
case "jpg": $ctype="image/jpg"; break;
case "tif": $ctype="application/force-download"; break;
default: $ctype="application/force-download";
}
header("Pragma: public"); // required
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private",false); // required for certain browsers
header("Content-Type: $ctype");
header("Content-Disposition: attachment; filename=\"".basename($fullPath)."\";" );
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".$fsize);
ob_clean();
flush();
readfile( $fullPath );
} else
die('File Not Found');
}
if (substr($_GET['image'],-3)=="tif") {
$image_urle=$_GET['image'];
$image_urleE=explode('/',$image_urle); //pour recuperer le chemin où se trouve le fichier
$file_path=$image_urleE[2]."/save.tif"; //construction du chemin
echo "<script langage=javascript>alert('export tiff ".$image_urle."')</script>";
echo "<script langage=javascript>alert('export tiff /".$file_path."')</script>";
echo "<br><br><input type=button value='Enregistrer la carte en format Geotiff' onclick=downloadFile(".$file_path.");>";
}
else {
echo "<img src='".$_GET['image']."'>";
$image_urleE=explode('/',$image_urle); //pour recuperer le chemin où se trouve le fichier
$file_path=$image_urleE[2]."/".$image_urleE[3]; //construction du chemin
echo "<script langage=javascript>alert('export tiff /".$file_path."')</script>";
echo "<br><br><input type=button value='Enregistrer image' onclick=downloadFile(".$file_path.");>";
echo "<script langage=javascript>alert('export png')</script>";
echo "<br><font>Pour enregistrer l'image, faites un clic droit sur l'image<br>puis enregister sous...</font>";
}
echo "<br><br><input type=button value='Retour Atlas' onclick=document.location='main.php'>";
?> |
Partager