-3

help me to solve the problem .

I have wrote my code like this :

function copy(){
    $folder     = "PDF";
    $file       = "2016-01-001_01-00.pdf";
    $files      = "ftp://10.242.42.154/adk_rkakl2016s"." ".substr($file,8,3)."/".substr($file,12,2)."/".$folder."/"."2016-01-001_01-00.pdf";
    $newfile    = 'files/backup_file/2017-01-001_01-00.pdf';

   if (!copy($files, $newfile)) {
      echo "failed to copy $files...\n";
        }else {
      echo "copied $file into $newfile\n";
        }
} 

i want to copy file from another server, but the result like this :

Severity: Warning Message: copy(): connect() failed: Connection refused Filename: controllers/Download_adk.php Line Number: 146

please help me

3
  • 1
    nobody will put any effort for this question, given that you put 0 effort in structuring it. Do not post images of code, but rather use SO functionality to show us the code. Thanks Commented Nov 28, 2017 at 9:38
  • 2
    "Connection refused" = the remote server is not letting your script do this. There is no way for anyone here to tell why, you'll have to talk to the administrator of the remote server. Commented Nov 28, 2017 at 9:38
  • Possible duplicate of Copy file from remote server or URL Commented Nov 28, 2017 at 9:39

1 Answer 1

-1

Since it is saying connection refused, Please check whether you are able to view the PDF in browser. If you can view pdf that is on the same machine as your program, then it might be that the server won't send the pdf unless you are a real user. In that case, modifying the browser identification string might fix your problem.

If you cannot view the pdf from your browser, then I guess, we have to check for some other problem.

Sign up to request clarification or add additional context in comments.

2 Comments

I have check in my browser, then the result is i can not view the PDF in browser, The remote server i want to access is linux, it using samba too then what should i do for next?
Then check out the reason, why you are unable to view

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.