Jump to content
Sign in to follow this  
adhossain

Copy file from remote Server to another Remote Server

Recommended Posts

I want to use a php script so that when I access the page, the browser copy the file from server to another server. Say, a file is in www.google.com/file.exe and when I open the page, the file will be copied to www.myserver.com/download location. pls tell me indetails coz I know only a little about PHP.Thanks

Share this post


Link to post
Share on other sites

You can use file_get_contents() to get a remote file then you can use file_put_contents() to write to second server where the script will run. Second server must have url file open option in php.ini on

Share this post


Link to post
Share on other sites

I haven't actually tried this, but I believe you should be able to do things with just copy(), like:

copy('http://www.google.com/file.exe', 'ftp://user:pass@www.myserver.com/download/file.exe');

(assuming "user" and "pass" are adjusted to your actual credentials for your FTP server that should be running on www.myserver.com)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×