Connecting Tech Pros Worldwide Forums | Help | Site Map

PHP FTP (French user please)

Sylvain GRAVERON
Guest
 
Posts: n/a
#1: Jan 26 '06
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.sql';
$destination='/var/www/toitetjoie/maj/liste_vacpli.sql';
echo $source."<br>";
echo $destination."<br>";
// paramètres de connexion FTP
$ftp_serveur=('192.168.99.20');
$conn_id=ftp_connect($ftp_serveur);
echo $conn_id."<br>";
$reslogin=ftp_login($conn_id,'cepas','tetj');
echo $reslogin."<br>";
$resput=ftp_put($conn_id,"$destination","$source", FTP_BINARY);
echo $resput."<br>";
ftp_quit($conn_id);

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

Voici le résultat des echos :

//srv-fic01/TeJCommun/site_web_admin/liste_vacpli.sql
/var/www/toitetjoie/maj/liste_vacpli.sql
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
Guest
 
Posts: n/a
#2: Jan 26 '06

re: PHP FTP (French user please)


Sylvain,

Mais pourquoi tant de " ?
[color=blue]
>[/color]
$resput=ftp_put($conn_id,"$destination","$source", FTP_BINARY);
<

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

Tu as éssayé

$resput=ftp_put($conn_id,$destination,$source,FTP_ BINARY);

??

Lennart Björk
Marc
Guest
 
Posts: n/a
#3: Jan 26 '06

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
Justin Koivisto
Guest
 
Posts: n/a
#4: Jan 26 '06

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.com
http://koivi.com
Sylvain GRAVERON
Guest
 
Posts: n/a
#5: Jan 26 '06

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.sql';
$destination='/var/www/toitetjoie/maj/liste_vacpli.sql';
echo $source."<br>";
echo $destination."<br>";
// paramèters FTP
$ftp_serveur=('192.168.99.20');
$conn_id=ftp_connect($ftp_serveur);
echo $conn_id."<br>";
$reslogin=ftp_login($conn_id,'cepas','tetj');
echo $reslogin."<br>";
$resput=ftp_put($conn_id,"$destination","$source", FTP_BINARY);
echo $resput."<br>";
ftp_quit($conn_id);

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

This de result of echos :

//srv-fic01/TeJCommun/site_web_admin/liste_vacpli.sql
/var/www/toitetjoie/maj/liste_vacpli.sql
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


SG
Guest
 
Posts: n/a
#6: Jan 26 '06

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,"$destination","$source", FTP_BINARY);
> <
>
> Le Manuel PHP dit
> // upload a file
> if (ftp_put($conn_id, $remote_file, $file, FTP_BINARY)) {
> echo "successfully uploaded $file\n";
> } else {
> echo "There was a problem while uploading $file\n";
> }
>
> Tu as éssayé
>
> $resput=ftp_put($conn_id,$destination,$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.sql';

What do you think about this ?

Tks

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

Cordialement

SG

Justin Koivisto
Guest
 
Posts: n/a
#7: Jan 26 '06

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.sql';
> $destination='/var/www/toitetjoie/maj/liste_vacpli.sql';
> echo $source."<br>";
> echo $destination."<br>";
> // paramèters FTP
> $ftp_serveur=('192.168.99.20');
> $conn_id=ftp_connect($ftp_serveur);
> echo $conn_id."<br>";
> $reslogin=ftp_login($conn_id,'cepas','tetj');
> echo $reslogin."<br>";
> $resput=ftp_put($conn_id,"$destination","$source", FTP_BINARY);
> echo $resput."<br>";
> ftp_quit($conn_id);
>
> ************************************************** ****************
>
> This de result of echos :
>
> //srv-fic01/TeJCommun/site_web_admin/liste_vacpli.sql
> /var/www/toitetjoie/maj/liste_vacpli.sql
> 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_exists($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.com
http://koivi.com
Lennart Björk
Guest
 
Posts: n/a
#8: Jan 27 '06

re: PHP FTP (French user please)


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

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,"$destination","$source", 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
Bent Stigsen
Guest
 
Posts: n/a
#9: Jan 27 '06

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.sql';
>
> 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]
SG
Guest
 
Posts: n/a
#10: Jan 27 '06

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.sql';
>>
>> 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


Bent Stigsen
Guest
 
Posts: n/a
#11: Jan 27 '06

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
Closed Thread