I recently configured phpseclib 2.0 for my server; so I'm quite new to this. When trying to upload a jpg image whose file is less than 1 MB via a normal HTML form and PHP using phpseclib, the image gets uploaded exactly where I want it to be, however with a file size of only 14 bytes (970 KB is the original file size). Any help? My code below:
// Establish the SFTP connection
$sftp = new \phpseclib\Net\SFTP('www.myhost.com');
// Login with username and password, and inform if the login was successful
if (!$sftp->login('myuser','mypassword')) {
$uploadAnswer = 'SFTP Connection failed!';
} else {
$uploadAnswer = 'SFTP Connection succesful!';
// migrate to root folder
$rootPath = $sftp->pwd();
// Create destination Path
$destinationPath = $rootPath.'/myfolder/'.$_FILES['myupload']['name'];
// Load the file onto the server, and inform if upload was successful
if (!$sftp->put($destinationPath,$_FILES['myupload']['tmp_name'])) {
$uploadAnswer = "There's been a problem with the Upload!";
} else {
$uploadAnswer = 'File successfully uploaded!';
}
}
When I run this, the message 'File successfully uploaded!' also gets displayed properly. What's happening here??