I'm trying to transfer files to a shared hosting account (godaddy) and it's failing:
Warning: ssh2_scp_send(): Failure creating remote file: failed to send file in 'local/file/path'
I have SSH2 installed and the connection is working. I even ran a ssh2_exec command to see if I can affect the remote server and I was able to create a directory. I also successfully used scp directly on the command line going both ways... As a further troubleshooting attempt, I reversed the file paths and created a remote server file for it to attempt downloading, I get this error:
failed to open stream: No such file or directory
I called the host to make sure I'm using the correct absolute file path, I've tried many variations, and I still get this error. I think my issue lies somewhere with the remote file path.
The problem code is below:
$localpath=$_SERVER['DOCUMENT_ROOT'].'/local_file_path/' ;
$remotepath = 'website.com/public_html/folder/' ;
$connection = ssh2_connect('website.com', 22);
ssh2_auth_password($connection,'username','password' );
ssh2_scp_send($connection,"$localpath"."SUCCESS.txt", "$remotepath"."SUCCESS.txt", 0644);
I am also having issues trying to use sftp via PHP. I read elsewhere on the web that you have to use double quotes on the file paths, whenever they fail, the printed path appears correct, but perhaps I'm missing something?
UPDATE
I logged into the shared hosting account via sftp with filezilla and discovered that, when copied, the full url path is different then what I was being given when logged in threw regular ftp. I can now upload a file, but, I can't seem to download just yet, ironically... I still get the error about not being able to locate the file path on the remote server.
question from:
https://stackoverflow.com/questions/65908523/error-to-send-file-with-php-and-sftp-connection 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…