473,698 Members | 2,149 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

kamill
71 New Member
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 5917
Atli
5,058 Recognized Expert Expert
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 New Member
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
jpr0325
4 New Member
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 New Member
Dear jpr0325

Thanks for reply but this script can copy files/dir from remote server ("server.nam e") 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 Recognized Expert Expert
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
4830
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 Authentication set up and it worked just fine. Then I realized that I needed to have some pages unsecure. I then created 2 directories. One named Secure and the other named Public. I placed my web.config file in my
1
3355
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 advance, ant
0
2590
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, for the questions. 1. A button on my control executes the System.IO.Directory.GetDirectories funtion (the scanned directory resides on the hosting web server). What credentials is this
1
14227
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 difficulties copying the exe I am Trying string Source = @"c:\temp\test.exe" string Destination = @"Z:\test.exe" File.Copy(Source, Destination, true)
0
1391
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 difficulties copying the exe I am Trying string Source = @"c:\temp\test.exe" string Destination = @"Z:\test.exe" File.Copy(Source, Destination, true)
6
1635
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 project files to a copy directory on my local wwwroot and then FTP all those files and directories to my ISP account to be able to see the change on my web site. This is a lot of data to FTP every time (the bin directory alone is close to 4MB) Is...
3
2185
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 with FrontPage Server Extensions, but I don't manage to deploy the application to my web provider http root folder. When I run Copy Project, I get an error message just saying 'Unable to create Web project 'myname'. Not found.'.
1
4149
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, these will be the names of two directories. This time, make sure that the "sending" directory exists (and is, indeed, a directory). Make sure that the "receiving" directory exists, and if not, create it. Then, copy files from the sending directory to...
10
3217
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
5674
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 numbered from 4-22 only and leave rest all. I have written a code but its only copying one directory and its files and not others. Overall /test1/step_1/prodinit_1....30 and I want to copy to /test2/step_1/prodinit_4...22 #!/bin/csh -f set dir1 =...
0
8671
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8598
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9016
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8887
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6515
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5858
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4613
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2321
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
1997
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.