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

Langage PHP Discussion :

Opendir + accès réseau local


Sujet :

Langage PHP

  1. #1
    Membre régulier
    Profil pro
    Inscrit en
    Octobre 2004
    Messages
    113
    Détails du profil
    Informations personnelles :
    Localisation : France, Paris (Île de France)

    Informations forums :
    Inscription : Octobre 2004
    Messages : 113
    Points : 80
    Points
    80
    Par défaut Opendir + accès réseau local
    Salut à tousje voudrais savoir comment on peut avoir accès à un dossier du réseau local "\\\\Poste\\....." avec la fonction opendir. Je suis sous XP SP1 et la fonction opendir me retourne "Argumant is not valid" lors ce que j'essaye d'ouvrir mon dossier pour le copier. J'ai pas trouvé la réponse à mon problème en faisant une recherche avancée donc si quelqu'un pouvait m'aider.

    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
     
    function CopyFiles($source,$dest)
    		{  
    		   $folder = opendir($source);
    		   while($file = readdir($folder))
    		   {
    			   if ($file == '.' || $file == '..') {
    				   continue;
    			   }
     
    			   if(is_dir($source.'/'.$file))
    			   {
    				   mkdir($dest.'/'.$file,0777);
    				   CopyFiles($source.'/'.$file,$dest.'/'.$file);
    			   }
    			   else 
    			   {
    				   copy($source.'/'.$file,$dest.'/'.$file);
    			   }
     
    		   }
    		   closedir($folder);
    		   return 1;
    		}
     
    		$source = '\\\\POSTE1\\contrat_client';
    		$dest = 'C:\\Program Files\\EasyPHP1-7\\mysql\\data\\contrat_client';
    		CopyFiles($source,$dest);
     
    		$source = '\\\\POSTE1\\enregistrement';
    		$dest = 'C:\\Program Files\\EasyPHP1-7\\mysql\\data\\enregistrement';
    		CopyFiles($source,$dest);
    Merci de votre aide!!!!

  2. #2
    Membre éclairé Avatar de hansaplast
    Homme Profil pro
    Artisant logiciel
    Inscrit en
    Septembre 2005
    Messages
    948
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : France, Isère (Rhône Alpes)

    Informations professionnelles :
    Activité : Artisant logiciel
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Septembre 2005
    Messages : 948
    Points : 719
    Points
    719
    Par défaut
    5.0.0 path supporte l'enveloppe URL ftp://
    4.3.0 path peut aussi être n'importe quel URL qui supporte le listage de dossiers, par contre, seul l'enveloppe URL file:// supporte ceci en PHP 4.
    apperement,non, masi c'est surprenant, doit y avoir une autre methode

    dans les commentaire des user :

    In addition to notes above about IIS & PHP reading network shares, here's one solution that works better for me.

    in the management console I created a folder where my "read_dir" script runs. click on properties then select the security tab. here you can set the anonymous account to the standard IUSR_$computername% , BUT.. in this case I chose another account that I set up for reading my shares. (make sure login name and password match the credantials you set on the remote machin ;-))

    I use this to read a dir and it's contents into a searchable database. and it works like a charm...
    Matt Grimm
    06-Jun-2003 10:25
    Thought I could help clarify something with accessing network shares on a Windows network (2000 in this case), running PHP 4.3.2 under Apache 2.0.44.

    However you are logged into the Windows box, your Apache service must be running under an account which has access to the share. The easiest (and probably least safe) way for me was to change the user for the Apache service to the computer administrator (do this in the service properties, under the "Log On" tab). After restarting Apache, I could access mapped drives by their assigned drive letter ("z:\\") or regular shares by their UNC path ("\\\\shareDrive\\shareDir").
    mitka at actdev.com
    28-Sep-2002 01:42
    Re: Accessing network directories on W32

    In reply to the previous comments, to enable opendir() to open directories like "\\SOMEHOST\shareddir", with PHP+IIS:

    Follow the instructions here: http://support.microsoft.com/default.aspx?scid=kb;en-us;Q189408

    Check that the file share allows reads to IUSR_[HOSTNAME] user.
    kcgt at go dot com
    30-Aug-2002 04:14
    I don't know if this will work the same, but I was working with copy() in order to copy a file to a network drive using IIS.

    In order to be able to copy to a network drive, you have to have permissions for the user IUSR_computername where computername is the name of the computer that is running PHP. Once permissions were set up on the remote machine, PHP was able to access the remote files. I don't know if this will work the same with opendir, but it might be worth a try......
    url : http://fr.php.net/manual/fr/function.opendir.php

    bonne chance

  3. #3
    Membre éclairé Avatar de hansaplast
    Homme Profil pro
    Artisant logiciel
    Inscrit en
    Septembre 2005
    Messages
    948
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : France, Isère (Rhône Alpes)

    Informations professionnelles :
    Activité : Artisant logiciel
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Septembre 2005
    Messages : 948
    Points : 719
    Points
    719
    Par défaut
    Citation Envoyé par hansaplast
    5.0.0 path supporte l'enveloppe URL ftp://
    4.3.0 path peut aussi être n'importe quel URL qui supporte le listage de dossiers, par contre, seul l'enveloppe URL file:// supporte ceci en PHP 4.
    apperement,non, masi c'est surprenant, doit y avoir une autre methode

    dans les commentaire des user :
    (va voir sur le site directement, le rendu est pas terrible la, et l'odre chonologique inversé, c'est tout a la fin des user contributed notes)
    In addition to notes above about IIS & PHP reading network shares, here's one solution that works better for me.

    in the management console I created a folder where my "read_dir" script runs. click on properties then select the security tab. here you can set the anonymous account to the standard IUSR_$computername% , BUT.. in this case I chose another account that I set up for reading my shares. (make sure login name and password match the credantials you set on the remote machin ;-))

    I use this to read a dir and it's contents into a searchable database. and it works like a charm...
    Matt Grimm
    06-Jun-2003 10:25
    Thought I could help clarify something with accessing network shares on a Windows network (2000 in this case), running PHP 4.3.2 under Apache 2.0.44.

    However you are logged into the Windows box, your Apache service must be running under an account which has access to the share. The easiest (and probably least safe) way for me was to change the user for the Apache service to the computer administrator (do this in the service properties, under the "Log On" tab). After restarting Apache, I could access mapped drives by their assigned drive letter ("z:\\") or regular shares by their UNC path ("\\\\shareDrive\\shareDir").
    mitka at actdev.com
    28-Sep-2002 01:42
    Re: Accessing network directories on W32

    In reply to the previous comments, to enable opendir() to open directories like "\\SOMEHOST\shareddir", with PHP+IIS:

    Follow the instructions here: http://support.microsoft.com/default.aspx?scid=kb;en-us;Q189408

    Check that the file share allows reads to IUSR_[HOSTNAME] user.
    kcgt at go dot com
    30-Aug-2002 04:14
    I don't know if this will work the same, but I was working with copy() in order to copy a file to a network drive using IIS.

    In order to be able to copy to a network drive, you have to have permissions for the user IUSR_computername where computername is the name of the computer that is running PHP. Once permissions were set up on the remote machine, PHP was able to access the remote files. I don't know if this will work the same with opendir, but it might be worth a try......
    url : http://fr.php.net/manual/fr/function.opendir.php

    bonne chance

  4. #4
    Membre régulier
    Inscrit en
    Octobre 2005
    Messages
    76
    Détails du profil
    Informations forums :
    Inscription : Octobre 2005
    Messages : 76
    Points : 76
    Points
    76
    Par défaut
    Je ne suis pas sur que ce soit possible...

    En fait, tu utilises pour celà une syntaxe propre à windows, et qui requier bien souvent une gestion des habilitations particuliere...

    La meilleur alternative que je pourrais te conseiller c'est de connecter le repertoire en question sur un lecteur réseau (Z:, Y: etc...) avec la commande DOS : NET USE... au besoin utilise la fonction "system" de PHP pour le faire depuis ton script...

    En gros ton script ressemblerai à ca :

    1) Detection d'une letre de lecteur non utilisée
    2) system('net use $mondossier $mon_lecteur');
    3) copie de mon fichier
    4) system('net use $mon_lecteur /delete');

    Vérifier la syntaxe de la commande NET sous Dos (c:\NET USE ?)

  5. #5
    Membre régulier
    Profil pro
    Inscrit en
    Octobre 2004
    Messages
    113
    Détails du profil
    Informations personnelles :
    Localisation : France, Paris (Île de France)

    Informations forums :
    Inscription : Octobre 2004
    Messages : 113
    Points : 80
    Points
    80
    Par défaut
    Mais il n'y aurait pas un moyen de convertir la source de manière à ce que celle-ci soit compréhensible pas valide. Un peu dans le même genre qu'une converstion d'un caractère en entier avec la fonction "atoi" en C?
    par ce que la source est bien une URL valide!!!!

Discussions similaires

  1. Réponses: 3
    Dernier message: 20/08/2014, 21h48
  2. [DEBUTANT]Accès au serveur Tomcat en réseau local
    Par fafat dans le forum Tomcat et TomEE
    Réponses: 9
    Dernier message: 25/11/2009, 19h32
  3. [Help] Accès fichiers local/réseau avec Firefox
    Par X-Nem dans le forum ASP.NET
    Réponses: 1
    Dernier message: 28/03/2007, 16h48
  4. Pb d'accès à EasyPHP sur un réseau local
    Par naoufal01 dans le forum Installation
    Réponses: 10
    Dernier message: 02/11/2006, 12h52
  5. réseau local (accès refusé)
    Par le y@m's dans le forum Sécurité
    Réponses: 7
    Dernier message: 24/07/2005, 13h48

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