Jump to content

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

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

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)

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...