Save a file on an sftp server in php

one text

Solution:

Your $sftp variable holds an SSH2 SFTP resource, so you can't just concat it as you do in your code when you call fopen.

According to the PHP documentation you'll need to get the intval of your SSH2 SFTP resource when calling fopen:

fopen("ssh2.sftp://" . intval($sftp) . "/DossierTest/$file_name", "w");

Source