Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

phpseclib NET_SFTP_STATUS_NO_SUCH_FILE: File not found when file DOES exist

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?

like image 379
Bad Programmer Avatar asked Dec 05 '25 04:12

Bad Programmer


1 Answers

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)
like image 172
Osmin M Avatar answered Dec 07 '25 18:12

Osmin M



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!