freelanceprogrammers.org Forum Index » PHP

"Copying" one file from one server to another


View user's profile Post To page top
fotospasaporte Posted: Tue Apr 26, 2005 12:35 pm


Joined: 26 Apr 2005

Posts: 10
"Copying" one file from one server to another
Hi everybody:
I need to copy one file from one server to another, and I would like
to know which is the best method in your opinion and how you would do it.

I have thought about three ways of doing it but i have never tried any
one of these:
1.-copy the file with a command in php (i don`t know if fsockopen has
to do with this).
2.-reading the file (readfile()??) and then writing it into a file.
3.-using a web service ( with this option, i want to copy or simply
receive the information in soap).

I am more interested in the third option, but i have no info. I would
thank references, URLs where i can read about web services in php.

Please give your opinion depending in two type of files:
1.-using a .txt
2.-using a .php

Thanks a lot,
Miguel 聲gel.
Reply with quote
Send private message
View user's profile Post To page top
attanasio@... Posted: Tue Apr 26, 2005 1:57 pm


Joined: 19 Mar 2005

Posts: 12
"Copying" one file from one server to another
hi,
if the files are stored in *nix servers you could simply use the UNIX scp
function passed through the php exec function. I don`t know if it works by
might be an idea.
@see http://it2.php.net/manual/en/function.exec.php
@see http://www.scit.wlv.ac.uk/cgi-bin/mansec?1+scp
greez
Oreste


[Non-text portions of this message have been removed]
Reply with quote
Send private message
View user's profile Post To page top
fotospasaporte Posted: Tue Apr 26, 2005 3:47 pm


Joined: 26 Apr 2005

Posts: 10
"Copying" one file from one server to another
The execution must be done through a php script automatically.
Let`s say, i have a button in a page, i click it and the operation is done.

On 4/26/05, Oreste Attanasio <attanasio@...> wrote:
>
>
> hi,
> if the files are stored in *nix servers you could simply use the UNIX scp
> function passed through the php exec function. I don`t know if it works by
> might be an idea.
> @see http://it2.php.net/manual/en/function.exec.php
> @see http://www.scit.wlv.ac.uk/cgi-bin/mansec?1+scp
> greez
> Oreste
>
> [Non-text portions of this message have been removed]
>
> PHP Data object relational mapping generator -
> http://www.meta-language.net/
> Yahoo! Groups Links
>
>
>
>
>


[Non-text portions of this message have been removed]
Reply with quote
Send private message
View user's profile Post To page top
attanasio@... Posted: Tue Apr 26, 2005 4:08 pm


Joined: 19 Mar 2005

Posts: 12
"Copying" one file from one server to another
well you could write a function like
function my_copy($file_path, $dest_server, $dest_username, $from_server,
$from_username, $dest_path) {
return exec("scp -B $from_username@$from_server:$file_path
$dest_username@$dest_server:$dest_path");
}
passing the parameters from a webform or hidden input values..
note:
- this works only if you have ssh access to both servers, if you don`t, you
can generate a key in order to allow access
see http://acd.ucar.edu/~fredrick/linux/scp.html
- the -B parameter is for avoiding the server from promting for password
bye
Oreste
On 4/26/05, Miguel Angel Gonzalez <miguelangel.gonzalezm@...> wrote:
>
>
> The execution must be done through a php script automatically.
> Let`s say, i have a button in a page, i click it and the operation is
> done.
>
> On 4/26/05, Oreste Attanasio <attanasio@...> wrote:
> >
> >
> > hi,
> > if the files are stored in *nix servers you could simply use the UNIX
> scp
> > function passed through the php exec function. I don`t know if it works
> by
> > might be an idea.
> > @see http://it2.php.net/manual/en/function.exec.php
> > @see http://www.scit.wlv.ac.uk/cgi-bin/mansec?1+scp
> > greez
> > Oreste
> >
> > [Non-text portions of this message have been removed]
> >
> > PHP Data object relational mapping generator -
> > http://www.meta-language.net/
> > Yahoo! Groups Links
> >
> >
> >
> >
> >
>
> [Non-text portions of this message have been removed]
>
>
> PHP Data object relational mapping generator -
> http://www.meta-language.net/
> Yahoo! Groups Links
>
>
>
>
>


--
Oreste Attanasio
attanasio@...


[Non-text portions of this message have been removed]
Reply with quote
Send private message
View user's profile Post To page top
markus@... Posted: Tue Apr 26, 2005 4:15 pm


Joined: 26 Apr 2005

Posts: 8
"Copying" one file from one server to another
MAG> The execution must be done through a php script automatically.
MAG> Let`s say, i have a button in a page, i click it and the operation is done.

Why not using FTP function on PHP? it`s easier and doable :)
see php manual for the example.

Markus
`After All, You`re Only Human`
Reply with quote
Send private message
View user's profile Post To page top
uthayaa_p Posted: Wed Apr 27, 2005 9:06 am


Joined: 12 Apr 2005

Posts: 19
"Copying" one file from one server to another
Hi,
You can copy file from one server to another
through PHP FTP functions.

Please refer the following url
http://in2.php.net/manual/en/ref.ftp.php

Any way you need the FTP conection details for the
remote server to transfer files

Regards
uthaya


--- fotospasaporte <miguelangel.gonzalezm@...>
wrote:
>
> Hi everybody:
> I need to copy one file from one server to another,
> and I would like
> to know which is the best method in your opinion and
> how you would do it.
>
> I have thought about three ways of doing it but i
> have never tried any
> one of these:
> 1.-copy the file with a command in php (i don`t know
> if fsockopen has
> to do with this).
> 2.-reading the file (readfile()??) and then writing
> it into a file.
> 3.-using a web service ( with this option, i want to
> copy or simply
> receive the information in soap).
>
> I am more interested in the third option, but i have
> no info. I would
> thank references, URLs where i can read about web
> services in php.
>
> Please give your opinion depending in two type of
> files:
> 1.-using a .txt
> 2.-using a .php
>
> Thanks a lot,
> Miguel 聲gel.
>
>
>
>

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
Reply with quote
Send private message
View user's profile Post To page top
bansalakhil3... Posted: Wed Apr 27, 2005 9:43 am


Joined: 21 Apr 2005

Posts: 9
"Copying" one file from one server to another
hello,
Try this
<?php
// set up basic connection
$conn_id = ftp_connect($ftp_server);

// login with username and password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);

// check connection
if ((!$conn_id) || (!$login_result)) {
echo "FTP connection has failed!";
echo "Attempted to connect to $ftp_server for user $ftp_user_name";
exit;
} else {
echo "Connected to $ftp_server, for user $ftp_user_name";
}

// upload the file
$upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY);

// check upload status
if (!$upload) {
echo "FTP upload has failed!";
} else {
echo "Uploaded $source_file to $ftp_server as $destination_file";
}

// close the FTP stream
ftp_close($conn_id);
?>

On 4/27/05, uthaya kumar <uthayaa_p@...> wrote:
>
>
> Hi,
> You can copy file from one server to another
> through PHP FTP functions.
>
> Please refer the following url
> http://in2.php.net/manual/en/ref.ftp.php
>
> Any way you need the FTP conection details for the
> remote server to transfer files
>
> Regards
> uthaya
>
> --- fotospasaporte <miguelangel.gonzalezm@...>
> wrote:
> >
> > Hi everybody:
> > I need to copy one file from one server to another,
> > and I would like
> > to know which is the best method in your opinion and
> > how you would do it.
> >
> > I have thought about three ways of doing it but i
> > have never tried any
> > one of these:
> > 1.-copy the file with a command in php (i don`t know
> > if fsockopen has
> > to do with this).
> > 2.-reading the file (readfile()??) and then writing
> > it into a file.
> > 3.-using a web service ( with this option, i want to
> > copy or simply
> > receive the information in soap).
> >
> > I am more interested in the third option, but i have
> > no info. I would
> > thank references, URLs where i can read about web
> > services in php.
> >
> > Please give your opinion depending in two type of
> > files:
> > 1.-using a .txt
> > 2.-using a .php
> >
> > Thanks a lot,
> > Miguel 聲gel.
> >
> >
> >
> >
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>
> PHP Data object relational mapping generator -
> http://www.meta-language.net/
> Yahoo! Groups Links
>
>
>
>
>


--
Akhil Bansal


[Non-text portions of this message have been removed]
Reply with quote
Send private message
View user's profile Post To page top
fotospasaporte Posted: Wed Apr 27, 2005 4:30 pm


Joined: 26 Apr 2005

Posts: 10
"Copying" one file from one server to another
Hi everybody:
Thanks for your advice.
I have investigated in this way, and i recommend the ftp class that pear is
offering, though i am not going to use it, because i need something that is
the fastest possible and i will use a smaller class to ftp.

I have other questions:
1.-the file am going to pass by ftp is vital so that the webs that are going
to receive it will not work if the connection is closed or whatever and the
file uploaded is not received properly.
You have to take in mind that the file is uploaded automatically without
human intervention, so nobody is going to verify if everything worked well.

How can the webs that receive the file verify that the info inside is ok?.

I have thing of writing something at the end of the file so that if when the
php of one of the webs include it, it should verify the tag at the end to
confirm.

Which other things can you tell so that the php file that includes the file
uploaded, knows it is ok.

If you want to know more, the next step is that if the php file knows that
the file uploaded is corrupt, this php file will read from one older.

2.-Any links for web services will be appreciated (not about google, paypal
etc...).

Adios,
Miguel 聲gel.



On 4/27/05, Akhil Bansal <bansalakhil30.10@...> wrote:
>
>
> hello,
> Try this
> <?php
> // set up basic connection
> $conn_id = ftp_connect($ftp_server);
>
> // login with username and password
> $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
>
> // check connection
> if ((!$conn_id) || (!$login_result)) {
> echo "FTP connection has failed!";
> echo "Attempted to connect to $ftp_server for user $ftp_user_name";
> exit;
> } else {
> echo "Connected to $ftp_server, for user $ftp_user_name";
> }
>
> // upload the file
> $upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY);
>
> // check upload status
> if (!$upload) {
> echo "FTP upload has failed!";
> } else {
> echo "Uploaded $source_file to $ftp_server as $destination_file";
> }
>
> // close the FTP stream
> ftp_close($conn_id);
> ?>
>
> On 4/27/05, uthaya kumar <uthayaa_p@...> wrote:
> >
> >
> > Hi,
> > You can copy file from one server to another
> > through PHP FTP functions.
> >
> > Please refer the following url
> > http://in2.php.net/manual/en/ref.ftp.php
> >
> > Any way you need the FTP conection details for the
> > remote server to transfer files
> >
> > Regards
> > uthaya
> >
> > --- fotospasaporte <miguelangel.gonzalezm@...>
> > wrote:
> > >
> > > Hi everybody:
> > > I need to copy one file from one server to another,
> > > and I would like
> > > to know which is the best method in your opinion and
> > > how you would do it.
> > >
> > > I have thought about three ways of doing it but i
> > > have never tried any
> > > one of these:
> > > 1.-copy the file with a command in php (i don`t know
> > > if fsockopen has
> > > to do with this).
> > > 2.-reading the file (readfile()??) and then writing
> > > it into a file.
> > > 3.-using a web service ( with this option, i want to
> > > copy or simply
> > > receive the information in soap).
> > >
> > > I am more interested in the third option, but i have
> > > no info. I would
> > > thank references, URLs where i can read about web
> > > services in php.
> > >
> > > Please give your opinion depending in two type of
> > > files:
> > > 1.-using a .txt
> > > 2.-using a .php
> > >
> > > Thanks a lot,
> > > Miguel 聲gel.
> > >
> > >
> > >
> > >
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Tired of spam? Yahoo! Mail has the best spam protection around
> > http://mail.yahoo.com
> >
> > PHP Data object relational mapping generator -
> > http://www.meta-language.net/
> > Yahoo! Groups Links
> >
> >
> >
> >
> >
>
> --
> Akhil Bansal
>
>
> [Non-text portions of this message have been removed]
>
> PHP Data object relational mapping generator -
> http://www.meta-language.net/
> Yahoo! Groups Links
>
>
>
>
>


[Non-text portions of this message have been removed]
Reply with quote
Send private message
View user's profile Post To page top
markus@... Posted: Wed Apr 27, 2005 9:11 pm


Joined: 26 Apr 2005

Posts: 8
"Copying" one file from one server to another
MAG> Which other things can you tell so that the php file that includes the file
MAG> uploaded, knows it is ok.

MD5? just like if you download Linux ISO from the internet, to confirm
that file ISO you downloaded is not corrupt you will need to check the
MD5 signature of the ISO file.

Markus
`After All, You`re Only Human`
Reply with quote
Send private message
View user's profile Post To page top
derekscruggs Posted: Wed Apr 27, 2005 10:57 pm


Joined: 05 Apr 2005

Posts: 11
"Copying" one file from one server to another
I`m looking for a class or function that, from a numeric input, will return
the description for a time zone. For example:

//-5 is timezone for New York

get_tzDescription(-5) //returns EST

The closest thing I`ve seen is putenv("TZ=US/Eastern"), then using
date(`T`), but this assumes I have all the settings for TZ mapped to their
integers.

I would love a class or function that I can query for this info. Any
suggestions?

-Derek
Reply with quote
Send private message
Post new topic Reply to topic
Display posts from previous:   
 

All times are GMT
Page 1 of 1
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Freelace Website Designer - Customer web design and software building.
China Wholesale - Electronics Products
Character Studio - Tutorials and Help