On Windows, I had trouble using ssh2_scp_send: files copied to a remote server where incomplete (truncated) and/or locked (error message : "access denied"). The back-end is also on Windows, using CopSSH (cygwin-based SSH server).

The SSH session was kept open - and the file were never flushed to disk.

There's a workaround though - make an explicit call to "exit" to close the session (flushing file content to disk):

If the server you are sending to is ubuntu 8 or 9 and you can't send files then check that your user has write permissions for /dev/null. Gets me every time. Add the line:chmod 666 /dev/nullto /etc/rc.local before the exit 0 line.