I have installed Apache server on one EC2 instance to serve files in Amazon EFS file system. Then I mount EFS under apache root /var/www/html. I have created subfolders under this path. Now I would like to upload files to that folder from my web application using php.
I have tried with phpseclib/SFTP. Am I doing is right?
include_once($dir.'vendor/autoload.php'); $key = PublicKeyLoader::load(file_get_contents($ppkpath)); $ssh = new SFTP('ec2-xx-xxx-xxx-xxx.compute-1.amazonaws.com'); if (!$ssh->login('ec2-user', $key)) { exit('Login Failed'); }else{ echo "Logged in"; } $file_name = $_FILES['file_path']['name']; $file_tmp =$_FILES['file_path']['tmp_name']; $uploadPath = "/var/www/html/efsmount/Foldername"; //if (ssh2_scp_send($ssh, $_FILES["file_path"]["tmp_name"], $uploadPath, 0644)) { if ($ssh->put($uploadPath, $_FILES["file_path"]["tmp_name"], SFTP::SOURCE_LOCAL_FILE)) { $sftp->chmod(0644, $uploadPath); echo "Uploaded"; } else { echo "Upload Failed"; } Output is: Upload Failed. No other error messages.