Afficher fichier pdf dans mon navigateur
Résolu
stephane07
Messages postés
172
Date d'inscription
Statut
Membre
Dernière intervention
-
stephane07 Messages postés 172 Date d'inscription Statut Membre Dernière intervention -
stephane07 Messages postés 172 Date d'inscription Statut Membre Dernière intervention -
Bonjour,
j'ai stocker dans ma BD mysql un fichier pdf et je souhaiterais afficher le contenu du fichier dans une page de mon navigateur. Voici le code que j'ai essayer je crois que quelque chose manque...
Merci de m'aider
<?php
require_once("connexion.php");
header('Content-type: application/pdf');
$sql="SELECT doc_numerisation FROM document WHERE doc_code='".$_GET['code']."' ";
$result=mysql_query($sql);
$pdfdata=mysql_fetch_array($result);
$pdf=extract($pdfdata);
?>
j'ai stocker dans ma BD mysql un fichier pdf et je souhaiterais afficher le contenu du fichier dans une page de mon navigateur. Voici le code que j'ai essayer je crois que quelque chose manque...
Merci de m'aider
<?php
require_once("connexion.php");
header('Content-type: application/pdf');
$sql="SELECT doc_numerisation FROM document WHERE doc_code='".$_GET['code']."' ";
$result=mysql_query($sql);
$pdfdata=mysql_fetch_array($result);
$pdf=extract($pdfdata);
?>
A voir également:
- Afficher fichier pdf dans mon navigateur
- Lire le coran en français pdf - Télécharger - Histoire & Religion
- Fichier bin - Guide
- Fichier epub - Guide
- Fichier rar - Guide
- Comment réduire la taille d'un fichier - Guide
9 réponses
<?php $db = mysql_connect('localhost', 'root', ''); mysql_select_db('test',$db); $sql = 'SELECT * FROM fichier_pdf'; $req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error()); while($data = mysql_fetch_assoc($req)) { echo '<a href="'.$data['fichier'].'">'.$data['nom'].'</a>'; } mysql_close(); ?>
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question
Merci, j'avais déjà elaboré un code quand je l'execute j'ai comme erreur une variable non défini au niveau du paramètre $_FILES. Pouriez vous m'aider à corriger mon code. Télécharger mon fichier index.php à cette adresse https://www.cjoint.com/?3KAwSDAsSNv
# ----------------------------FICHIER index.php
<?php
require_once("connexion.php");
$requete2="SELECT type_document_code, type_document_libel FROM type_document";
$resultat2=mysql_query($requete2);
if(isset($_POST['send']))
{
$data = file_get_contents($_FILES["doc_numerisation"]["tmp_name"]);
$requete="INSERT INTO document SET doc_code='".$_POST['doc_code']."', doc_auteur='".$_POST['doc_auteur']."', doc_titre='".$_POST['doc_titre']."', doc_edition='".$_POST['doc_edition']."', doc_nbre_page='".$_POST['doc_nbre_page']."', issn='".$_POST['issn']."', doc_dat_publicat='".$_POST['doc_dat_publicat']."', doc_niv_diff='".$_POST['doc_niv_diff']."', doc_dispo='".$_POST['doc_dispo']."', doc_numerisation='".mysql_escape_string("$data")."' ";
$resultat=mysql_query($requete);
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Centre de Documentation</title>
</head>
<body>
<form id="docform" name="formdoc" method="post" action="index.php" enctype="multipart/form_data">
<table width="600" border="0" cellspacing="0" cellpadding="5" align="center">
<tr>
<td>
Type document:
</td>
<td colspan=5>
<select name="type_doc_libelle">
<?php while($document2=mysql_fetch_array($resultat2)) { ?>
<option><?php echo $document2['type_document_libel'];?></option>
<?php } ?>
</select>
</td>
</tr>
<tr>
<td>
code:
</td>
<td>
<input type="text" name="doc_code" />
</td>
<td>
titre:
</td>
<td>
<input type="text" name="doc_titre"/>
</td>
<td>
auteur:
</td>
<td>
<input type="text" name="doc_auteur"/>
</td>
</tr>
<tr>
<td nowrap="deprecated">
Edition:
</td>
<td>
<input type="text" name="doc_edition"/>
</td>
<td nowrap="deprecated">
nbre de Page:
</td>
<td>
<input type="text" name="doc_nbre_page"/>
</td>
<td nowrap="deprecated">
ISSN:
</td>
<td>
<input type="text" name="issn"/>
</td>
</tr>
<tr>
<td nowrap="deprecated">
date publication:
</td>
<td>
<input type="text" name="doc_dat_publicat"/>
</td>
<td nowrap="deprecated">
Disponibilité:
</td>
<td>
<input type="text" name="doc_dispo"/>
</td>
<td>
niveau diffusion:
</td>
<td>
<input type="text" name="doc_niv_diff"/>
</td>
</tr>
<tr>
<td nowrap="deprecated">
</td>
<td>
<input type="hidden" name="MAX_FILE_SIZE" value="30000" />
</td>
<td>
<input type="file" name="file" />
</td>
<td>
</td>
<td>
</td>
<td>
<input type="submit" name="send" value="Envoyer"/>
</td>
</tr>
</table>
</form>
</form>
</body>
</html>
<?php
require_once("connexion.php");
$requete2="SELECT type_document_code, type_document_libel FROM type_document";
$resultat2=mysql_query($requete2);
if(isset($_POST['send']))
{
$data = file_get_contents($_FILES["doc_numerisation"]["tmp_name"]);
$requete="INSERT INTO document SET doc_code='".$_POST['doc_code']."', doc_auteur='".$_POST['doc_auteur']."', doc_titre='".$_POST['doc_titre']."', doc_edition='".$_POST['doc_edition']."', doc_nbre_page='".$_POST['doc_nbre_page']."', issn='".$_POST['issn']."', doc_dat_publicat='".$_POST['doc_dat_publicat']."', doc_niv_diff='".$_POST['doc_niv_diff']."', doc_dispo='".$_POST['doc_dispo']."', doc_numerisation='".mysql_escape_string("$data")."' ";
$resultat=mysql_query($requete);
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Centre de Documentation</title>
</head>
<body>
<form id="docform" name="formdoc" method="post" action="index.php" enctype="multipart/form_data">
<table width="600" border="0" cellspacing="0" cellpadding="5" align="center">
<tr>
<td>
Type document:
</td>
<td colspan=5>
<select name="type_doc_libelle">
<?php while($document2=mysql_fetch_array($resultat2)) { ?>
<option><?php echo $document2['type_document_libel'];?></option>
<?php } ?>
</select>
</td>
</tr>
<tr>
<td>
code:
</td>
<td>
<input type="text" name="doc_code" />
</td>
<td>
titre:
</td>
<td>
<input type="text" name="doc_titre"/>
</td>
<td>
auteur:
</td>
<td>
<input type="text" name="doc_auteur"/>
</td>
</tr>
<tr>
<td nowrap="deprecated">
Edition:
</td>
<td>
<input type="text" name="doc_edition"/>
</td>
<td nowrap="deprecated">
nbre de Page:
</td>
<td>
<input type="text" name="doc_nbre_page"/>
</td>
<td nowrap="deprecated">
ISSN:
</td>
<td>
<input type="text" name="issn"/>
</td>
</tr>
<tr>
<td nowrap="deprecated">
date publication:
</td>
<td>
<input type="text" name="doc_dat_publicat"/>
</td>
<td nowrap="deprecated">
Disponibilité:
</td>
<td>
<input type="text" name="doc_dispo"/>
</td>
<td>
niveau diffusion:
</td>
<td>
<input type="text" name="doc_niv_diff"/>
</td>
</tr>
<tr>
<td nowrap="deprecated">
</td>
<td>
<input type="hidden" name="MAX_FILE_SIZE" value="30000" />
</td>
<td>
<input type="file" name="file" />
</td>
<td>
</td>
<td>
</td>
<td>
<input type="submit" name="send" value="Envoyer"/>
</td>
</tr>
</table>
</form>
</form>
</body>
</html>