PHP Function SSH2SFTP_Unlink
php function ssh2_sftp_unlink is an inbuilt php function that deletes files from the remote filesystem. It returns True if successful and False on failure. It accepts the $filename as a parameter and the context as an optional argument to modify its nature.
ssh2_sftp_unlink() works just like the unlink() function in UNIX. It can be called only when the web server user has read and write permission to the remote file system.
For example, if you want to run many exec orders throught ssh2 at the same time and each one output is a separate file then you will need to close the stream after each order else the next one can't be read. So you will need to call ssh2_sftp_unlink() after each exec order to unlink the stream and make it usable again.
Besides the ssh2_sftp_unlink(), there are some other important ssh2 functions that you might need from time to time. Here are a few of them:
This code creates a connection to the sftp server using the ssh2_connect function, authenticates with a username and password using the ssh2_auth_password function, opens an sftp session with the ssh2_sftp_open function, then uses the ssh2_scp_send function to upload a file. It forces 3des-cbc when sending packets, any strength aes cipher when receiving packets and no compression in either direction. It also includes an option to set the sftp.chunksize to 1Mb, which makes the upload faster by sending it in multiple chunks of 32K each instead of one large chunk at a time.