PHP FTP (French user please)

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Sylvain GRAVERON

    PHP FTP (French user please)

    Hi
    Sorry I don't speak english very vell and no reply in fr news ! ! !

    Bonjour,

    J'essai d'envoyer par FTP en php un fichier dont le nom, la destination
    et la source seront toujours les mêmes.

    Voici le code : (rien de compliqué)

    *************** *************** *************** *************** ******

    $source='//srv-fic01/TeJCommun/site_web_admin/liste_vacpli.sq l';
    $destination='/var/www/toitetjoie/maj/liste_vacpli.sq l';
    echo $source."<br>";
    echo $destination."< br>";
    // paramètres de connexion FTP
    $ftp_serveur=(' 192.168.99.20') ;
    $conn_id=ftp_co nnect($ftp_serv eur);
    echo $conn_id."<br>" ;
    $reslogin=ftp_l ogin($conn_id,' cepas','tetj');
    echo $reslogin."<br> ";
    $resput=ftp_put ($conn_id,"$des tination","$sou rce",FTP_BINARY );
    echo $resput."<br>";
    ftp_quit($conn_ id);

    *************** *************** *************** *************** ******

    Voici le résultat des echos :

    //srv-fic01/TeJCommun/site_web_admin/liste_vacpli.sq l
    /var/www/toitetjoie/maj/liste_vacpli.sq l
    Resource id #2
    1

    ------------------------------------------------------

    Ce que je trouve étrange (mais il y a surement une explication) c'est
    que lorsque je passe par un Bt parcourir et l'utilsation de la
    viariable $_FILES avec la propriété name, cela fonctionne :

    temp=$_FILES['url'];
    $_SESSION['vs_pj']=$temp['name'];

    Le système gere alors une sorte de fichier temporaire et le ftp
    fonctionne...

    Merci d'avance pour votre aide précieuse....

    Cordialement,

    SG


  • Lennart Björk

    #2
    Re: PHP FTP (French user please)

    Sylvain,

    Mais pourquoi tant de " ?
    [color=blue]
    >[/color]
    $resput=ftp_put ($conn_id,"$des tination","$sou rce",FTP_BINARY );
    <

    Le Manuel PHP dit
    // upload a file
    if (ftp_put($conn_ id, $remote_file, $file, FTP_BINARY)) {
    echo "successful ly uploaded $file\n";
    } else {
    echo "There was a problem while uploading $file\n";
    }

    Tu as éssayé

    $resput=ftp_put ($conn_id,$dest ination,$source ,FTP_BINARY);

    ??

    Lennart Björk

    Comment

    • Marc

      #3
      Re: PHP FTP (French user please)

      Sylvain GRAVERON wrote:[color=blue]
      > Sorry I don't speak english very vell and no reply in fr news ! ! ![/color]

      Salut!

      Votre Anglais est bon, vous devriez essayer d'expliquer votre problème
      en Anglais.

      Your English is good, you should try to explain your problem in English.

      Marc

      Comment

      • Justin Koivisto

        #4
        Re: PHP FTP (French user please)

        Sylvain GRAVERON wrote:[color=blue]
        > Hi
        > Sorry I don't speak english very vell and no reply in fr news ! ! ![/color]

        Contrary to popular belief, those of us who are ignorant and monolingual
        can actually read broken English quite well. It's easier to read broken
        (or bad) English than to try and listen to it.

        Your English is much better than my <insert any other language here>

        --
        Justin Koivisto, ZCE - justin@koivi.co m

        Comment

        • Sylvain GRAVERON

          #5
          Re: PHP FTP (French user please)

          > Sylvain GRAVERON wrote:[color=blue][color=green]
          >> Hi
          >> Sorry I don't speak english very vell and no reply in fr news ! ! ![/color]
          >
          > Contrary to popular belief, those of us who are ignorant and monolingual
          > can actually read broken English quite well. It's easier to read broken
          > (or bad) English than to try and listen to it.
          >
          > Your English is much better than my <insert any other language here>[/color]

          Ok, I try... (sorry=) ;-(

          I try do upload on file that i known name and directory in php

          Code :

          *************** *************** *************** *************** ******

          $source='//srv-fic01/TeJCommun/site_web_admin/liste_vacpli.sq l';
          $destination='/var/www/toitetjoie/maj/liste_vacpli.sq l';
          echo $source."<br>";
          echo $destination."< br>";
          // paramèters FTP
          $ftp_serveur=(' 192.168.99.20') ;
          $conn_id=ftp_co nnect($ftp_serv eur);
          echo $conn_id."<br>" ;
          $reslogin=ftp_l ogin($conn_id,' cepas','tetj');
          echo $reslogin."<br> ";
          $resput=ftp_put ($conn_id,"$des tination","$sou rce",FTP_BINARY );
          echo $resput."<br>";
          ftp_quit($conn_ id);

          *************** *************** *************** *************** ******

          This de result of echos :

          //srv-fic01/TeJCommun/site_web_admin/liste_vacpli.sq l
          /var/www/toitetjoie/maj/liste_vacpli.sq l
          Resource id #2
          1

          ------------------------------------------------------

          If and do the same think with a browse button, it's OK. The system use
          $_FILES [name]


          temp=$_FILES['url'];
          $_SESSION['vs_pj']=$temp['name'];

          The system call probably a temporary file and upload

          Thank you for help.

          Sincerely,

          SG


          Comment

          • SG

            #6
            Re: PHP FTP (French user please)

            Lennart Björk avait écrit le 26/01/2006 :[color=blue]
            > Sylvain,
            >
            > Mais pourquoi tant de " ?
            >[color=green]
            > >[/color]
            > $resput=ftp_put ($conn_id,"$des tination","$sou rce",FTP_BINARY );
            > <
            >
            > Le Manuel PHP dit
            > // upload a file
            > if (ftp_put($conn_ id, $remote_file, $file, FTP_BINARY)) {
            > echo "successful ly uploaded $file\n";
            > } else {
            > echo "There was a problem while uploading $file\n";
            > }
            >
            > Tu as éssayé
            >
            > $resput=ftp_put ($conn_id,$dest ination,$source ,FTP_BINARY);
            >
            > ??
            >
            > Lennart Björk[/color]

            Yes

            It's don't works.
            Maybe i find. I forgot the protocol.
            File is on a files server (windows) Monday I will try this :

            $source=file:///'srv-fic01/TeJCommun/site_web_admin/liste_vacpli.sq l';

            What do you think about this ?

            Tks

            --
            ------------------------------------------

            Cordialement

            SG

            Comment

            • Justin Koivisto

              #7
              Re: PHP FTP (French user please)

              Sylvain GRAVERON wrote:[color=blue][color=green]
              >> Sylvain GRAVERON wrote:[color=darkred]
              >>> Hi
              >>> Sorry I don't speak english very vell and no reply in fr news ! ! ![/color]
              >>
              >> Contrary to popular belief, those of us who are ignorant and monolingual
              >> can actually read broken English quite well. It's easier to read broken
              >> (or bad) English than to try and listen to it.
              >>
              >> Your English is much better than my <insert any other language here>[/color]
              >
              > Ok, I try... (sorry=) ;-(
              >
              > I try do upload on file that i known name and directory in php
              >
              > Code :
              >
              > *************** *************** *************** *************** ******
              >
              > $source='//srv-fic01/TeJCommun/site_web_admin/liste_vacpli.sq l';
              > $destination='/var/www/toitetjoie/maj/liste_vacpli.sq l';
              > echo $source."<br>";
              > echo $destination."< br>";
              > // paramèters FTP
              > $ftp_serveur=(' 192.168.99.20') ;
              > $conn_id=ftp_co nnect($ftp_serv eur);
              > echo $conn_id."<br>" ;
              > $reslogin=ftp_l ogin($conn_id,' cepas','tetj');
              > echo $reslogin."<br> ";
              > $resput=ftp_put ($conn_id,"$des tination","$sou rce",FTP_BINARY );
              > echo $resput."<br>";
              > ftp_quit($conn_ id);
              >
              > *************** *************** *************** *************** ******
              >
              > This de result of echos :
              >
              > //srv-fic01/TeJCommun/site_web_admin/liste_vacpli.sq l
              > /var/www/toitetjoie/maj/liste_vacpli.sq l
              > Resource id #2
              > 1
              >
              > ------------------------------------------------------
              >
              > If and do the same think with a browse button, it's OK. The system use
              > $_FILES [name]
              >
              >
              > temp=$_FILES['url'];
              > $_SESSION['vs_pj']=$temp['name'];
              >
              > The system call probably a temporary file and upload
              >
              > Thank you for help.[/color]

              I'm thinking that your problem is the source file. You reference it
              starting with "//"

              try adding something like this to check on that:

              var_dump(file_e xists($source)) ;

              if you get "bool(false )" then your problem is there. In order to put the
              file somewhere, the system needs to know where the source is. If it
              doesn't think it exists, then you can't successfully upload it...


              BTW - your english isn't that bad at all. Definitely enough to get the
              message across. ;)

              --
              Justin Koivisto, ZCE - justin@koivi.co m

              Comment

              • Lennart Björk

                #8
                Re: PHP FTP (French user please)

                Sylvain,
                [color=blue]
                >[/color]
                $source=file:///'srv-fic01/TeJCommun/site_web_admin/liste_vacpli.sq l';

                What do you think about this ?
                <

                I think you should start by checking if the file really is there (or
                even available to you there). Justin Koivisto gives you that hint in his
                message here.

                As a general rule I think you schould check the results of your actions.
                You mentioned that you got
                [color=blue]
                >[/color]
                Resource id #2
                1
                <
                What does that '1' mean? Isn't that the result of your[color=blue]
                >[/color]
                $resput=ftp_put ($conn_id,"$des tination","$sou rce",FTP_BINARY );
                <
                ?
                The result of the ftp_put() seems to be ok. But if there is nothing to
                put nothing is put, bien que le put lui-même marche très bien. You can
                test how ftp_put() works in this respect by asking it to send something
                you know is not there, and keep a tight eye on the return value.

                Lennart Björk

                Comment

                • Bent Stigsen

                  #9
                  Re: PHP FTP (French user please)

                  Lennart Björk wrote:[color=blue]
                  > Sylvain,
                  >[color=green]
                  > >[/color]
                  > $source=file:///'srv-fic01/TeJCommun/site_web_admin/liste_vacpli.sq l';
                  >
                  > What do you think about this ?
                  > <[/color]

                  "file:" would only work if accessible through local filesystem.
                  [color=blue]
                  >
                  > I think you should start by checking if the file really is there (or
                  > even available to you there). Justin Koivisto gives you that hint in his
                  > message here.[/color]

                  Quite so.

                  As far as I know, PHP has no wrapper for the smb-protocol so, unless
                  natively supported by the OS, PHP cannot directly access shared
                  folders on remote windows servers.

                  Perhaps the simplest would be to let the linux (or what have you),
                  access the windows server through http or ftp.


                  /Bent

                  [snip]

                  Comment

                  • SG

                    #10
                    Re: PHP FTP (French user please)

                    Bent Stigsen a pensé très fort :[color=blue]
                    > Lennart Björk wrote:[color=green]
                    >> Sylvain,
                    >>[color=darkred]
                    >> >[/color]
                    >> $source=file:///'srv-fic01/TeJCommun/site_web_admin/liste_vacpli.sq l';
                    >>
                    >> What do you think about this ?
                    >> <[/color]
                    >
                    > "file:" would only work if accessible through local filesystem.
                    >[color=green]
                    >>
                    >> I think you should start by checking if the file really is there (or even
                    >> available to you there). Justin Koivisto gives you that hint in his message
                    >> here.[/color]
                    >
                    > Quite so.
                    >
                    > As far as I know, PHP has no wrapper for the smb-protocol so, unless natively
                    > supported by the OS, PHP cannot directly access shared folders on remote
                    > windows servers.
                    >
                    > Perhaps the simplest would be to let the linux (or what have you), access the
                    > windows server through http or ftp.
                    >
                    >
                    > /Bent
                    >
                    > [snip][/color]

                    Ok,
                    i'll try with ftp or http on my win2003 to My debian. (My debian is
                    installed with samba... Maybe ! ! !)

                    I try monday and i 'll say to you the result.

                    :'( I known my english is very very BAAAAAAAAAD ! ! ! !

                    SG

                    --
                    ------------------------------------------

                    Cordialement

                    SG


                    Comment

                    • Bent Stigsen

                      #11
                      Re: PHP FTP (French user please)

                      SG wrote:
                      [snip][color=blue]
                      > i'll try with ftp or http on my win2003 to My debian. (My debian is
                      > installed with samba... Maybe ! ! !)[/color]

                      Yes, that is also an option.

                      For example, if the share is open to anonymous access then try:
                      smbclient -N //srv-fic01/TeJCommun/site_web_admin/

                      If ok, then you should get a prompt like:
                      smb: \>

                      smbclient is just like a ftp client, where you can get and put files.
                      ? will give list of commands.

                      If above is ok, then you could mount the share on the local
                      filesystem, with:

                      mount -t smbfs -o guest //srv-fic01/TeJCommun/site_web_admin/ /mnt/xyz

                      And then access the files from /mnt/xyz (or whereever)

                      If username and password is required for accessing the windows server,
                      then look at the man-pages for smbclient and smbmnt.

                      I haven't used the above myself, so I can't say how stable it is. I
                      might be a bit critical, but I would try to reboot either machines,
                      and see if it reconnects properly. And just to be safe, have a
                      cron-job do a check once every hour.

                      [color=blue]
                      > I try monday and i 'll say to you the result.
                      >
                      > :'( I known my english is very very BAAAAAAAAAD ! ! ! ![/color]

                      It is really not as bad as you think. The fact that you can see your
                      own limitation is a good sign.

                      Use it, and it *will* get better.


                      /Bent

                      Comment

                      Working...