3

I am using phpseclib to upload a file to a remote server. Previously, my script worked fine, but a few weeks ago it appears to have stopped working. I am getting a

NET_SFTP_STATUS_NO_SUCH_FILE: File not found from $sftp->put.

The problem is that the file to be uploaded to the server does exist. Plus, the code worked previously anyways.

Since the script was previously working, it seems that maybe perhaps some settings for the target server may have changed.

Does anyone have any ideas or suggestions for troubleshooting this?

hakre
  • 193,403
  • 52
  • 435
  • 836
Bad Programmer
  • 3,642
  • 13
  • 46
  • 53

1 Answers1

7

I experienced this issue just yesterday. In my case, I was passing the local/remote file names in the wrong order, e.g.

if($sftp->put($filename,$filenameRemote,NET_SFTP_LOCAL_FILE))

but after changing it to

($sftp->put($filenameRemote, $filename, NET_SFTP_LOCAL_FILE)) 

it worked fine.

Since this worked for you in the past I'd definitely look at permissions for the local/remote files or directories where they reside. Also, if you haven't already, enable debugging for more details

define('NET_SFTP_LOGGING', NET_SFTP_LOG_COMPLEX)
Inder Kumar Rathore
  • 39,458
  • 17
  • 135
  • 184
Osmin M
  • 88
  • 3