简体   繁体   中英

User phpseclib0.3.1 - sftp get - When I leave local file blank, I don't get correct content of file

If I use a local filename, the filename is properly copied, however, if you leave local filename empty, you are supposed to receive the content of the file.

Example code:

$stat = $sftp->get('xmlfile.cml','xmlfile.xml'); print "$stat
";

(This works fine)

$xmlcontent = $sftp->get('cp1301080801_status.xml'); print "Content of file = $xmlcontent<>";

*(This prints what looks more like the stat of the file instead of the content. It starts with the date (which is the modofoed timestamp of file, followed by some numbers and the name of the web server repeated about 10 times with a number after it that increases each time - like maybe a port number or byte offset) *

It would make things easier if I didn't have to fopen the local file after the transfer. Anyone have an idea what is going on here?

Can you post a copy of the logs? Here's an example of how to get them:

http://phpseclib.sourceforge.net/ssh/examples.html#logging

Note the define() and the $ssh->getLog() stuff.

As for the specific problem you're having... what does print "$stat" do? It should print "1".

Also, fwiw, you're opening two different files in your example. My best guess, atm, is that you're thinking you're opening the same files and expecting the content to be the same when in fact they should be different and that what you're getting with both of the $sftp->get()'s is, in fact, correct.

The logs will tell us for sure.

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