简体   繁体   中英

remote files have 0 bytes when uploaded via sftp with phpseclib

i have Server 2008 R2 with xampp (1.7.7) running. i try to use sftp with phpseclib. when i load the php page manually, all works fine. when the page is loaded via cronjob, i get 0 Byte files on the remote Computer.

here is the php code:

$sftp = new Net_SFTP('remote.server');
if (!$sftp->login('user', 'password')) {
    exit('Login Failed');
}
$sftp->put($filename.".DAT", $filename.".DAT", NET_SFTP_LOCAL_FILE);

and here the .bat for the cronjob:

@E:\WSERVER\xampp\php\php.exe -f E:\WSERVER\xampp\htdocs\sites\anq\file.php

what could be the Problem? the local files are fine, either way...

regards j

The second parameter to your Net_SFTP::put() call is as follows:

$filename.".DAT"

My guess is that that's a relative path and that the directory the cron job (or Windows Scheduler task) is being ran out of isn't the same as it is when you run it manually.

ie. the solution would be to make the second parameter be an absolute path to the file location.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM