ok, now all scripts work
the solution was:
news.php:
Code: Select all
<?php
include("dbconnect.php");
$query = "SELECT news.id_news, news.author, news.date, news.title, news.news, pdf.id_pdf, pdf.Nome, doc.id_doc, doc.Nome
FROM news
LEFT JOIN pdf ON (news.id_news = pdf.id_sharepdf)
LEFT JOIN doc ON (news.id_news = doc.id_sharedoc)";
$result = mysql_query($query) or die(mysql_error());
while(list($id_news, $author, $date, $title, $news, $id_pdf, $nome_pdf, $id_doc, $nome_doc) = mysql_fetch_row($result)) {
echo "
<div id="riga"><h3>Titolo: $title</h3></div>
<div id="riga1"=><h4>News inserita il $date - <b>Autore:</b> $author</h4></div>
<div id="riga2"><h5>$news</h5>
<img src="../../../immagini/pdf.gif" width="16" height="16" style="float: left;" />
<a href="download.php?action=download&type=pdf&Id=$id_news"/><h6>$nome_pdf</h6></a>
<img src="../../../immagini/word.gif" width="16" height="16" style="float: left;" />
<a href="download.php?action=download&type=doc&Id=$id_news"><h6>$nome_doc</h6></a>
</div>";
}
?>
and for
download.php:
Code: Select all
<?php
include("dbconnect.php");
switch($_GET['type']) {
case 'pdf':
$query = "SELECT DatiBinari, Nome, Type FROM pdf WHERE id_sharepdf = '{$_GET['Id']}'";
break;
case 'doc':
$query = "SELECT DatiBinari, Nome, Type FROM doc WHERE id_sharedoc = '{$_GET['Id']}'";
break;
default:
echo "Dati non corretti";
exit;
break;
}
$result = mysql_query($query) or die(mysql_error());
if($result) {
$ris = mysql_fetch_assoc($result);
header("Content-Type: {$ris['Type']}");
header("Expires: ". gmdate("D, d M Y H:i:s") . " GMT");
header("Content-Disposition: inline; filename={$ris['Nome']}");
header("Content-Transfer-Encoding: inline");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Pragma: public");
echo $ris['DatiBinari'];
exit;
}
?>
but i still have a little and annoiyng problem.
when i open a doc file from browser (IE), MS Word ask me in a little windows to "convert file from:" with a list of applications inside.
it's a header's problem? how can i solve this problem?
thanks