Codice PHP:
<?php
if(!isset($_GET)) $_GET = $HTTP_GET_VARS;
if($_GET["action"] && $_GET["Id"] && is_numeric($_GET["Id"])) {
// CONNESSIONE AL MYSQL
@mysql_connect("localhost", "nome", "passwd") or die("Connessione fallita !");
// SELEZIONE DATABASE
@mysql_select_db("mio_db") or die("Selezione Database fallita !");
switch($_GET["action"]) {
// VISUALIZZAZIONE
case "view" :
$query = "SELECT DatiBinari, Type FROM file_binari WHERE Id = '" . $_GET["Id"] . "'";
$select = @mysql_query($query) or die("Query fallita !");
$result = @mysql_fetch_array($select);
$data = $result["DatiBinari"];
$type = $result["Type"];
Header("Content-type: $type");
echo $data;
break;
// DOWNLOAD
case "download" :
$query = "SELECT DatiBinari, Nome, Type FROM file_binari WHERE Id = '" . $_GET["Id"] . "'";
$select = @mysql_query($query) or die("Query fallita !");
$result = @mysql_fetch_array($select);
$data = $result["DatiBinari"];
$name = $result["Nome"];
$type = $result["Type"];
// SE IL BROWSER È INTERNET EXPLORER
if(ereg("MSIE ([0-9].[0-9]{1,2})", $_SERVER["HTTP_USER_AGENT"])) {
header("Content-Type: application/octetstream");
header("Content-Disposition: inline; filename=$name");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Pragma: public");
} else {
header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename=$name");
header("Expires: 0");
header("Pragma: no-cache");
}
echo $data;
break;
default :
// DEFAULT CASE, NESSUNA AZIONE
break;
} // endswitch
// CHIUDIAMO LA CONNESSIONE
@mysql_close();
} //endif
?>
questo è il codice che uso per estrarre le immagini inserite nel database
ho provato anche la gd_info() che mi hai consigliato mi sembra che sia tutto a posto, cmq ti posto il risultato della funzione
array(12) { ["GD Version"]=> string(27) "bundled (2.0.34 compatible)" ["FreeType Support"]=> bool(true) ["FreeType Linkage"]=> string(13) "with freetype" ["T1Lib Support"]=> bool(true) ["GIF Read Support"]=> bool(true) ["GIF Create Support"]=> bool(true) ["JPG Support"]=> bool(true) ["PNG Support"]=> bool(true) ["WBMP Support"]=> bool(true) ["XPM Support"]=> bool(false) ["XBM Support"]=> bool(true) ["JIS-mapped Japanese Font Support"]=> bool(false) }
grazie per l'aiuto ma proprio non mi ci riesco più a raccapezzare in questa cosa..