mpietro
User
 Fresh Boarder
| Posts: 2 |   | Karma: 0
|
ssh2.sftp issue - 2006/06/07 16:07
The following code works and has been tested up to the while loop. The fopen statement returned a "Resource #6" id and reports no errors. The code hangs in the while loop. Any ideas as to what can be happening here?
<?php $connection = ssh2_connect('my.site.com', 22); $test = ssh2_auth_password($connection, 'username', 'password');
$sftp = ssh2_sftp($connection); if($sftp == false) { die('Unable to request SFTP subsystem'); }
$selected_file = "this.doc"; $file_mime_type="application/msword"; $truefilesize = filesize($selected_file);
header("Content-Type: " . $file_mime_type); header("Content-Disposition: attachment; filename=$selected_file"); header("Content-Length: " . $truefilesize);
$chunksize = 1*(1024*1024); // how many bytes per chunk $buffer = ''; $datapath = fopen('ssh2.sftp://username: password@my.site.com/var/www/html/members/pvip1/this.doc', 'rb'); if(!$datapath) { die('Unable to fopen'); }
while (!feof($datapath)) { $buffer = fread($datapath, $chunksize); print $buffer; } ?>
|