IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

PHP & Base de données Discussion :

Lien vers fichier texte


Sujet :

PHP & Base de données

  1. #1
    Membre du Club
    Inscrit en
    Juillet 2007
    Messages
    125
    Détails du profil
    Informations forums :
    Inscription : Juillet 2007
    Messages : 125
    Points : 46
    Points
    46
    Par défaut Lien vers fichier texte
    Bonjour,

    je cherche à realiser un lien qui me permette d'ouvrir un fichier text situé sur mon disque en lecture seule.

    le lien que j'ai me renvoi vers une page vide marlgré le chemin renseigne ($fp).

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
     
    <? session_start();?>
     
    <html>
    <head>
    <title>cretion</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <div align="center">
    <TBODY>
      <TR vAlign=top>
        <TD width=293 height=90><IMG height=90 
          src="logodoc.gif" width=1004 useMap=#logo 
          border=0><MAP name=logo><AREA shape=RECT coords=28,7,89,80 
            href="logodoc.gif" target="_blank"></MAP></TD>
    </TR>
    </TBODY>
      </div>
    <style type="text/css">
    <!--
    body {
    	background-color: #FFCC66;
    }
    -->
    </style></head>
     
    <body>
     
    <table width="746" height="65" bordercolor="#000099" border="1" > 
    <tr bordercolor="#330066"> 
    <td width="109"><div align="left"><span class="Style1">Num_Ars</span></div></td>
    <td width="109"><div align="left"><span class="Style1">Matricule</span></div></td>
    <td width="109"><div align="left"><span class="Style1">Prenom</span></div></td>
    <td width="109"><div align="left"><span class="Style1">Nom</span></div></td>
    <td width="109"><div align="left"><span class="Style1">Service</span></div></td>
    <td width="109"><div align="left"><span class="Style1">Date Archivage</span></div></td>
    <td width="109"><div align="left"><span class="Style1">Etiquette de l'archive</span></div></td>
    <td width="109"><div align="left"><span class="Style1">Type d'archive</span></div></td>
    <td width="109"><div align="left"><span class="Style1">Chemin de l'archive</span></div></td>
    <td width="109"><div align="left"><span class="Style1">Commentaire</span></div></td>
    <td width="109"><div align="left"><span class="Style1">Libelle de l'archve</span></div></td>
    <td width="109"><div align="left"><span class="Style1">lien vers le fichier detaillé de l'archive</span></div></td>
    </tr>
     
    <?$connexion = mysql_connect('xxx','xxx','');// Connexion à la base de donnée 
    mysql_select_db('ref',$connexion)  or die('Erreur de selection '.mysql_error()); 
    $requete = "SELECT Matricule,Nom,Prenom,Service.id_service,Libelle_Service,Num_Ars,E_Archive,D_Archive,Libelle,type_Archive.id_T_Archive,Libelle_T_Archive,C_Archive,Commentaire,Lien_fichier FROM arch,service,type_archive  WHERE arch_.id_t_archive = '".$_POST['Type_Archive']."'&& arch.id_service = service.id_service && arch.id_t_archive = type_archive.id_t_archive "; 
    $resultat = mysql_db_query('ref',$requete,$connexion) or die('Erreur de selection '.mysql_error()); // execution de la requete 
    mysql_close($connexion);// Fermeture de la connexion 
     
    $fp=fopen("c:/formulaire/robocopy.txt","r");
     
    while($rows = mysql_fetch_array($resultat)) 
    { 
        $Num_Ars = $rows['Num_Ars'];  
        $Matricule = $rows['Matricule']; 
        $Prenom = $rows['Prenom']; 
        $Nom = $rows['Nom']; 
        $Libelle_Service = $rows['Libelle_Service']; 
        $D_Archive = $rows['D_Archive']; 
        $E_Archive = $rows['E_Archive']; 
        $Libelle_T_Archive = $rows['Libelle_T_Archive']; 
        $C_Archive = $rows['C_Archive'];
        $Commentaire = $rows['Commentaire'];
        $Libelle = $rows['Libelle'];
    	$Lien_fichier = $rows['Lien_fichier'];
     
    echo "<tr>\n
    <td > $Num_Ars </td>\n 
    <td > $Matricule</td>\n 
    <td > $Prenom </td>\n 
    <td > $Nom </td>\n 
    <td > $Libelle_Service </td>\n 
    <td > $D_Archive </td>\n 
    <td > $E_Archive </td>\n 
    <td > $Libelle_T_Archive </td>\n 
    <td > $C_Archive </td>\n
    <td > $Commentaire </td>\n 
    <td > $Libelle </td>\n 
    <td > <a href=\"$fp\">$Lien_fichier<\a> </td>\n 
    </tr>\n";	
    }
     
    ?> 
     
     
     
     
     
     
    <input name="button" type="button"onClick="javascript:location.href='connexion_base.php'" value="retour au menu">
     
     
     
    </body>
    </html>

  2. #2
    Modérateur

    Avatar de MaitrePylos
    Homme Profil pro
    DBA
    Inscrit en
    Juin 2005
    Messages
    5 496
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 51
    Localisation : Belgique

    Informations professionnelles :
    Activité : DBA
    Secteur : Service public

    Informations forums :
    Inscription : Juin 2005
    Messages : 5 496
    Points : 12 596
    Points
    12 596
    Par défaut
    Bonjour, le chemin n'est pas correcte


    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    $fp=fopen("c:\\formulaire\\robocopy.txt","r");

  3. #3
    Membre du Club
    Inscrit en
    Juillet 2007
    Messages
    125
    Détails du profil
    Informations forums :
    Inscription : Juillet 2007
    Messages : 125
    Points : 46
    Points
    46
    Par défaut
    merci je l'ai modifier mais toujour rien.

    HTTP 404 - Fichier introuvable
    Internet Explorer

    http://127.0.0.1/Archivage/Resource%20id%20

    j'ai recuperer le type MIME text

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    header("Content-type: text/plain");
    sans + de succes, je continu de chercher

  4. #4
    Modérateur

    Avatar de MaitrePylos
    Homme Profil pro
    DBA
    Inscrit en
    Juin 2005
    Messages
    5 496
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 51
    Localisation : Belgique

    Informations professionnelles :
    Activité : DBA
    Secteur : Service public

    Informations forums :
    Inscription : Juin 2005
    Messages : 5 496
    Points : 12 596
    Points
    12 596
    Par défaut
    Ok, j'ai compris,

    tu veux mettre un lien vers ton fichier

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    <td > <a href=\"$fp\">$Lien_fichier<\a> </td>\n
    or la commande fopen ouvre un fichier et met son contenu dans une variable

    dans ton cas ceci devrais suffire

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
     
    $fp="c:\\formulaire\\robocopy.txt";
     
    <td > <a href=\"$fp\">$Lien_fichier<\a> </td>\n

  5. #5
    Membre du Club
    Inscrit en
    Juillet 2007
    Messages
    125
    Détails du profil
    Informations forums :
    Inscription : Juillet 2007
    Messages : 125
    Points : 46
    Points
    46
    Par défaut
    Salut,

    la methode ne change rien, j'ai veriefié mes droits sur le diques le nom du fichier et je l'ai deplacé vers c:

    le lien qui est affiché et comme suit,"je ne pense pas que cela gene l'affichage du fichier ?"

    DAF-2008-08-29-32659<\a>

    j'ai toujour une erreru HTTP 404 - Fichier introuvable
    Internet Explorer

    voici les modification apportées

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
     
    while($rows = mysql_fetch_array($resultat)) 
    { 
        $Num_Ars = $rows['Num_Ars'];  
        $Matricule = $rows['Matricule']; 
        $Prenom = $rows['Prenom']; 
        $Nom = $rows['Nom']; 
        $Libelle_Service = $rows['Libelle_Service']; 
        $D_Archive = $rows['D_Archive']; 
        $E_Archive = $rows['E_Archive']; 
        $Libelle_T_Archive = $rows['Libelle_T_Archive']; 
        $C_Archive = $rows['C_Archive'];
        $Commentaire = $rows['Commentaire'];
        $Libelle = $rows['Libelle'];
    	$filename = $rows['Lien_fichier'];
     
     
     
    $fp = fopen( "c:\\robocopy.txt","r" ); // Ouverture du fichier en lecture seule
    //$contents = fread( $fp, filesize( $filename ) ); //Récupère tout le contenu du fichier et le place dans une chaîne de caractères
     
     
     
    echo "<tr>\n
    <td > $Num_Ars </td>\n 
    <td > $Matricule</td>\n 
    <td > $Prenom </td>\n 
    <td > $Nom </td>\n 
    <td > $Libelle_Service </td>\n 
    <td > $D_Archive </td>\n 
    <td > $E_Archive </td>\n 
    <td > $Libelle_T_Archive </td>\n 
    <td > $C_Archive </td>\n
    <td > $Commentaire </td>\n 
    <td > $Libelle </td>\n 
     
    <td > <a href=\"$fp\">$filename<\a> </td>\n
     
    </tr>\n";	
    }
    fclose($fp); //Fermeture du fichier
    ?>

  6. #6
    Modérateur

    Avatar de MaitrePylos
    Homme Profil pro
    DBA
    Inscrit en
    Juin 2005
    Messages
    5 496
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 51
    Localisation : Belgique

    Informations professionnelles :
    Activité : DBA
    Secteur : Service public

    Informations forums :
    Inscription : Juin 2005
    Messages : 5 496
    Points : 12 596
    Points
    12 596
    Par défaut
    Et tu espère faire quoi là

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
     
     
    <a href=\"$fp\">$filename<\a>
    Parce que le href donne un lien, or toi tu essaye de donner le contenu du fichier, cela ne peut pas marcher.

    Alors soit tu donnes un lien vers ton fichier, et c'est ton navigateur qui se charge de te demander d'ouvrir un éditeur de texte dans ce cas cela-ce fais de cette façon

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
     
    $fp="c:\\formulaire\\robocopy.txt";
     
    <td > <a href=\"$fp\">$Lien_fichier<\a> </td>\n
    soit tu affiche le contenu du fichier dans ta page web,

    mais alors il faut ouvrir/lire/afficher/fermer le fichier voir ici

Discussions similaires

  1. [XSLT] transformation xml vers fichier .text !
    Par kader78190 dans le forum XSL/XSLT/XPATH
    Réponses: 1
    Dernier message: 03/11/2006, 12h45
  2. [Réseau] Liens vers fichiers sur un disque
    Par Kuuei dans le forum Langage
    Réponses: 13
    Dernier message: 21/05/2006, 23h51
  3. Export Table Acces vers fichier Texte
    Par ston dans le forum Access
    Réponses: 2
    Dernier message: 04/04/2006, 17h21
  4. SQL vers Fichier Texte
    Par annedjomo dans le forum MS SQL Server
    Réponses: 5
    Dernier message: 24/11/2005, 11h47
  5. Export vers fichier text
    Par Aurèl90 dans le forum Access
    Réponses: 10
    Dernier message: 26/10/2005, 10h26

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo