Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7218025
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T21:25:43+00:00 2026-05-28T21:25:43+00:00

I want to copy a file from a remote server to a local server

  • 0

I want to copy a file from a remote server to a local server via php. I’m not sure of the “best” approach to do this so I’ve tried a few different ways to accomplish this but I’m hitting roadblocks with those methods.

So I came up with a method using JSONP to (A) call the remote server and get the contents of the .php file and pass it back to the local server for the local script to then (B) call to a local php script and use file_put_contents to write the content to the local server.

All works fine UNTIL an ampersand is reached. The file write stops there.


Edit to show data coming back.

if ($mysqlErrorConnectServer || $mysqlErrorConnectDb || $mysqlErrorConfigTableMissing) {
    $errorMsg .= '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"'
                  . '"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'
                  . '<head>'
                  . '<title>Example website &copy; - Example description of example site</title>'
                  . '<style type="text/css">'

So if you look at the code coming back… there is a “&copy” which needs to be there to display the copyright symbol on the page… but it stops the file_put_contents from writing the rest of the file.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T21:25:44+00:00Added an answer on May 28, 2026 at 9:25 pm

    Copied from previous response to answer my own question.

    Here’s the answer to the problem. 🙂 Knew it would be something simple I had not run across yet. Before sending the data to the local write script (after receiving it back from the remote), I simply call encodeURIComponent() to my returned response and send it on to the local script to write.

    Works like a charm.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can Maven copy local file to a remote server using SSH? I want to
I only need to copy a file from a remote server to a local
I want to copy a file from A to B in C#. How do
I want to get the %tagname% from a file and copy them to a
I want to copy a binary master file in a new binary file. This
What I want to do with this script is to copy a file in
This script is to connect to different servers and copy a file from a
I've written a batch file to copy files from one server to another, however,
I'm trying to upload a folder from my local machine to a remote server
I want to read and copy file from jar file(for eg. application.xml from EAR

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.