par
Greg34 » 06 août 2009, 10:07
Bonjour,
Je suis en train de développer une page en php et j'ai un petit soucis. J'ai une fonction qui va chercher tous les fichiers présents dans des dossiers sur un serveur de fichier distant et ça ne marche pas. J'ai copié un de ces répertoires en local sur le serveur web et ça fonctionne.
Adresse distante: \\powxp200\d$\archive\COMPODISTRIB FACTURES
Adresse local: D:\archive\AEROCHEM FACTURES
J'ai déjà essayé de doubler les \ ( \\\\powxp200\\d$\\archive\\CALORIE FACTURES ) mais même effet.
Voici mon code:
Code : Tout sélectionner
<?php
function Insert_Num_Fact($Rep, $NomSoc, $connexion){
echo $Rep;
if ($handle = opendir($Rep)) {
while (false !== ($file = readdir($handle))) {
/*echo $file;
echo "<br>";*/
if(substr($file, -3) == "PDF"){
$query = "INSERT INTO GZ_LISTE_PDF(Numero, Societe) VALUES('$file', '$NomSoc')";
$result = odbc_exec($connexion,$query); //Execution de la requete
}
}
closedir($handle);
}
else echo "<br> erreur chemin <br>";
}
$RepAER = "D:\archive\AEROCHEM FACTURES";
$RepCAL = "\\\\powxp200\\d$\\archive\\CALORIE FACTURES";
$RepCMPDIS = "\\powxp200\d$\archive\COMPODISTRIB FACTURES";
$RepCMP20 = "\\powxp200\d$\archive\COMPOSITES20 FACTURES";
$RepCMP = "\\powxp200\d$\archive\COMPOSITES FACTURES";
$RepFRD = "\\powxp200\d$\archive\FROID FACTURES";
$RepGTC = "\\powxp200\d$\archive\GTC FACTURES";
$RepPLX = "\\powxp200\d$\archive\PLASTIQUES FACTURES";
$server="powxp200"; //Nom du serveur de la Db
$db="GZ_FACTURE_PDF_Test"; //Nom de la Db
$user="user"; //Nom utilisateur
$password="pass"; //Mot de passe
//Connexion à la Db
$connexion=odbc_connect("DRIVER=SQL Server;SERVER=".$server.";UID=".$user.";PWD=".$password.";DATABASE=".$db.";Address=".$server.",1433","","");
//Purge des tables
$query = "DELETE FROM GZ_LISTE_PDF";
$result = odbc_exec($connexion,$query); //Execution de la requete
if (htmlspecialchars($_POST['TOUTES']) != '')
Insert_Num_Fact($checkALL);
else{
if (htmlspecialchars($_POST['AEROCHEM']) != '')
Insert_Num_Fact($RepAER, htmlspecialchars($_POST['AEROCHEM']), $connexion);
if (htmlspecialchars($_POST['CALORIE']) != '')
Insert_Num_Fact($RepCAL, htmlspecialchars($_POST['CALORIE']), $connexion);
if (htmlspecialchars($_POST['COMPOSITES_DISTRIBUTION']) != '')
Insert_Num_Fact($RepCMPDIS, htmlspecialchars($_POST['COMPOSITES_DISTRIBUTION']), $connexion);
if (htmlspecialchars($_POST['COMPOSITES_20']) != '')
Insert_Num_Fact($RepCMP20, htmlspecialchars($_POST['COMPOSITES 20']), $connexion);
if (htmlspecialchars($_POST['COMPOSITES']) != '')
Insert_Num_Fact($RepCMP, htmlspecialchars($_POST['COMPOSITES']), $connexion);
if (htmlspecialchars($_POST['FROID']) != '')
Insert_Num_Fact($RepFRD, htmlspecialchars($_POST['FROID']), $connexion);
if (htmlspecialchars($_POST['GTC']) != '')
Insert_Num_Fact($RepGTC, htmlspecialchars($_POST['GTC']), $connexion);
if (htmlspecialchars($_POST['PLASTIQUES']) != '')
Insert_Num_Fact($RepPLX, htmlspecialchars($_POST['PLASTIQUES']), $connexion);
}
odbc_close($connect);
?>
Si quelqu'un peut m'aider à faire fonctionner le opendir avec les chemins réseaux merci par avance.
Greg
Bonjour,
Je suis en train de développer une page en php et j'ai un petit soucis. J'ai une fonction qui va chercher tous les fichiers présents dans des dossiers sur un serveur de fichier distant et ça ne marche pas. J'ai copié un de ces répertoires en local sur le serveur web et ça fonctionne.
Adresse distante: \\powxp200\d$\archive\COMPODISTRIB FACTURES
Adresse local: D:\archive\AEROCHEM FACTURES
J'ai déjà essayé de doubler les \ ( \\\\powxp200\\d$\\archive\\CALORIE FACTURES ) mais même effet.
Voici mon code:
[code]
<?php
function Insert_Num_Fact($Rep, $NomSoc, $connexion){
echo $Rep;
if ($handle = opendir($Rep)) {
while (false !== ($file = readdir($handle))) {
/*echo $file;
echo "<br>";*/
if(substr($file, -3) == "PDF"){
$query = "INSERT INTO GZ_LISTE_PDF(Numero, Societe) VALUES('$file', '$NomSoc')";
$result = odbc_exec($connexion,$query); //Execution de la requete
}
}
closedir($handle);
}
else echo "<br> erreur chemin <br>";
}
$RepAER = "D:\archive\AEROCHEM FACTURES";
$RepCAL = "\\\\powxp200\\d$\\archive\\CALORIE FACTURES";
$RepCMPDIS = "\\powxp200\d$\archive\COMPODISTRIB FACTURES";
$RepCMP20 = "\\powxp200\d$\archive\COMPOSITES20 FACTURES";
$RepCMP = "\\powxp200\d$\archive\COMPOSITES FACTURES";
$RepFRD = "\\powxp200\d$\archive\FROID FACTURES";
$RepGTC = "\\powxp200\d$\archive\GTC FACTURES";
$RepPLX = "\\powxp200\d$\archive\PLASTIQUES FACTURES";
$server="powxp200"; //Nom du serveur de la Db
$db="GZ_FACTURE_PDF_Test"; //Nom de la Db
$user="user"; //Nom utilisateur
$password="pass"; //Mot de passe
//Connexion à la Db
$connexion=odbc_connect("DRIVER=SQL Server;SERVER=".$server.";UID=".$user.";PWD=".$password.";DATABASE=".$db.";Address=".$server.",1433","","");
//Purge des tables
$query = "DELETE FROM GZ_LISTE_PDF";
$result = odbc_exec($connexion,$query); //Execution de la requete
if (htmlspecialchars($_POST['TOUTES']) != '')
Insert_Num_Fact($checkALL);
else{
if (htmlspecialchars($_POST['AEROCHEM']) != '')
Insert_Num_Fact($RepAER, htmlspecialchars($_POST['AEROCHEM']), $connexion);
if (htmlspecialchars($_POST['CALORIE']) != '')
Insert_Num_Fact($RepCAL, htmlspecialchars($_POST['CALORIE']), $connexion);
if (htmlspecialchars($_POST['COMPOSITES_DISTRIBUTION']) != '')
Insert_Num_Fact($RepCMPDIS, htmlspecialchars($_POST['COMPOSITES_DISTRIBUTION']), $connexion);
if (htmlspecialchars($_POST['COMPOSITES_20']) != '')
Insert_Num_Fact($RepCMP20, htmlspecialchars($_POST['COMPOSITES 20']), $connexion);
if (htmlspecialchars($_POST['COMPOSITES']) != '')
Insert_Num_Fact($RepCMP, htmlspecialchars($_POST['COMPOSITES']), $connexion);
if (htmlspecialchars($_POST['FROID']) != '')
Insert_Num_Fact($RepFRD, htmlspecialchars($_POST['FROID']), $connexion);
if (htmlspecialchars($_POST['GTC']) != '')
Insert_Num_Fact($RepGTC, htmlspecialchars($_POST['GTC']), $connexion);
if (htmlspecialchars($_POST['PLASTIQUES']) != '')
Insert_Num_Fact($RepPLX, htmlspecialchars($_POST['PLASTIQUES']), $connexion);
}
odbc_close($connect);
?>
[/code]
Si quelqu'un peut m'aider à faire fonctionner le opendir avec les chemins réseaux merci par avance.
Greg