473,386 Members | 1,883 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 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 5854
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 web.config file in the root with Forms...
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 System.IO.Directory.MOVE but don't know how to COPY. thanks in...
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 page. For more info please see the appendix. Now,...
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 this seems to be a trivial matter I am having...
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 this seems to be a trivial matter I am having...
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 page I currently rebuild the solution, copy the...
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 it to another folder on my machine works well...
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 two and only two command line arguments. Again,...
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 shutil.copy2(r"C:\test\test",r"C:\test1\test")
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 problem I am facing is, I have to copy files...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.