472,333 Members | 1,046 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,333 software developers and data experts.

how to copy directories/files from a remote directory using php?

kamill
71
I have two server one is window server as "A" and another is Linux server as "B".

I have a directory on server "A" which contains several files and sub directories. I want to copy directories/files from server "A" to server "B" using php. I have control on both server but i want to run PHP script into Linux server "B".

As i am not good in file handling so please help me to get rid from this problem.
Mar 8 '10 #1
5 5662
Atli
5,058 Expert 4TB
Hey.

To copy the files from server A, the files need to be made available to server B somehow. FTP, SMB, HTTP, or something like that.

Do you have the files shared in any way?
If yes, the how so?
If no, then you need to set something up.
Mar 8 '10 #2
kamill
71
Dear Atli,

Thanks for reply. Actually i want to use ftp related functions in below steps
1- Open ftp of server "A"
2-Open ftp of server "B"
3-Copy the content of "A" into "B"

I do not know this will work and if yes then how to implement this.

Regards,
Kamil
Mar 8 '10 #3
There are FTP functions available in PHP, which you can use to connect and get content from server.

Expand|Select|Wrap|Line Numbers
  1. $con = ftp_connect("server.name"); 
  2. $login_result = ftp_login ($con, "username", "password"); 
  3. ftp_get($con,'targetpath', 'sourcepath', FTP_BINARY);
Mar 8 '10 #4
kamill
71
Dear jpr0325

Thanks for reply but this script can copy files/dir from remote server ("server.name") to the local machine and i want to copy from remote server and want to upload into another server where i will run this script.

This will be helpful if you clear this script beacuse i have tried this but no luck.

Regards,
Kamil
Mar 9 '10 #5
Atli
5,058 Expert 4TB
Then what you need to do is
  1. Open two FTP connections, one for each server
  2. ftp_get the file from server A into either a temporary "buffer" file or a memory buffer (a simple variable should do)
  3. ftp_put the file from your buffer to it's new location on server B.
Use the examples provided above and in the manual (the links I posted above), and this should be no problem.
Mar 9 '10 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Billy Jacobs | last post by:
I have a website which has both secure and non-secure pages. I want to uses forms authentication. How do I accomplish this? Originally I had my...
1
by: Antonio Lopez Arredondo | last post by:
hi all !!! I need to copy a folder and its subfolders to another location; which class should I use ? could only find the...
0
by: Tess | last post by:
Hi, Long time reader, first time poster... Any help is appreciated. I have a few questions regarding Winform controls embedded within an html...
1
by: PRM | last post by:
Hi I have an ASp.net application using C#. I need to copy a file present on the web server machine to a remote machine on the network. Although...
0
by: PRM | last post by:
Hi I have an ASp.net application using C#. I need to copy a file present on the web server machine to a remote machine on the network. Although...
6
by: Wayne Wengert | last post by:
I am using VSNET 2003 to build an ASP.NET/VB set of pages. There are currently about a dozen aspx pages. When I make even a minor change to one...
3
by: Johnny | last post by:
Hi, I have created an ASP.NET application (let's call it FooBar) with VS.NET on my local machine, residing in http://localhost/FooBar. Deploying...
1
by: dkmarni | last post by:
Hi, I am trying to do this perl script, but not able to complete it successfully. Here is the description what the script has to do.. Accept...
10
by: yinglcs | last post by:
Hi, Is there a c library which does shutil.copy2() in python? Basically copy a file from 1 directory to another? import shutil import os ...
1
by: kumarboston | last post by:
Hi all, I am trying to copy couple of directories and their files to another place. Each directory have 25-30 files and numbered accordingly, the...
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: CD Tom | last post by:
This happens in runtime 2013 and 2016. When a report is run and then closed a toolbar shows up and the only way to get it to go away is to right...
0
by: CD Tom | last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.