Advertisement  
  Home arrow Forums
Main Menu
Login
Recent Forum Posts
 Wednesday, 07 January 2009
BostonPHP Forum  


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;
}
?>
  | | The administrator has disabled public write access.

      Topics Author Date
    thread link
ssh2.sftp issue
mpietro 2006/06/07 16:07
    thread link
thread linkthread link Re:ssh2.sftp issue
admin 2006/06/08 16:45
    thread link
thread linkthread linkthread link Re:ssh2.sftp issue
mpietro 2006/06/09 04:42
Show your support
Polls
What's the average PHP rate in Boston
 
What's the PHP rockstar rate in Boston
 
Tag Cloud
Podcast
The BostonPHP podcast Podcast
Full Feed
 
Go to top of page  Home | Wiki | Search | Forums | Job Board | Newsletter | Latest News | Reservations | Classified Ads | Podcast Archive | MyAccount |