468,247 Members | 1,325 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,247 developers. It's quick & easy.

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.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
Jan 26 '06 #1
10 1481
Sylvain,

Mais pourquoi tant de " ?

$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
Jan 26 '06 #2
Sylvain GRAVERON wrote:
Sorry I don't speak english very vell and no reply in fr news ! ! !


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
Jan 26 '06 #3
Sylvain GRAVERON wrote:
Hi
Sorry I don't speak english very vell and no reply in fr news ! ! !


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 - ju****@koivi.com
http://koivi.com
Jan 26 '06 #4
> Sylvain GRAVERON wrote:
Hi
Sorry I don't speak english very vell and no reply in fr news ! ! !


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>


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
Jan 26 '06 #5
SG
Lennart Björk avait écrit le 26/01/2006 :
Sylvain,

Mais pourquoi tant de " ?
>

$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


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

Jan 26 '06 #6
Sylvain GRAVERON wrote:
Sylvain GRAVERON wrote:
Hi
Sorry I don't speak english very vell and no reply in fr news ! ! !


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>


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.


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 - ju****@koivi.com
http://koivi.com
Jan 26 '06 #7
Sylvain,
$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
Resource id #2
1
<
What does that '1' mean? Isn't that the result of your

$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
Jan 27 '06 #8
Lennart Björk wrote:
Sylvain,
> $source=file:///'srv-fic01/TeJCommun/site_web_admin/liste_vacpli.sql';

What do you think about this ?
<


"file:" would only work if accessible through local filesystem.

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.


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]
Jan 27 '06 #9
SG
Bent Stigsen a pensé très fort :
Lennart Björk wrote:
Sylvain,
>

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

What do you think about this ?
<


"file:" would only work if accessible through local filesystem.

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.


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]


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
Jan 27 '06 #10
SG wrote:
[snip]
i'll try with ftp or http on my win2003 to My debian. (My debian is
installed with samba... Maybe ! ! !)
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.

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

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


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
Jan 27 '06 #11

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

38 posts views Thread by Haines Brown | last post: by
1 post views Thread by Gina | last post: by
8 posts views Thread by Ess355 | last post: by
13 posts views Thread by jd | last post: by
9 posts views Thread by kaustubh.deo | last post: by
2 posts views Thread by Marcel Saucier | last post: by
3 posts views Thread by bss | last post: by
reply views Thread by NPC403 | last post: by
reply views Thread by kermitthefrogpy | last post: by
reply views Thread by zattat | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.