79454550

Date: 2025-02-20 12:49:39
Score: 0.5
Natty:
Report link

We can use scp command for moving files from current to destination directory.

if ($request->hasFile('front_picture_path')) {
                    $file = $request->file('front_picture_path');
                    $filename = $file->getClientOriginalName();
            
                    // Store temporarily in storage
                    $tempPath = $file->storeAs('temp', $filename);

    $remoteUser = 'myusername';
    $remoteHost = 'myhost';
    $remotePath = "mypath";
    $password =   'mypassword';
    
    $scpCommand = "scp " . storage_path("app/{$tempPath}") . " {$remoteUser}@{$remoteHost}:{$remotePath}";
    shell_exec($scpCommand);

If you are using a password,then create a Pem file and transfer files using pem key without passowrd.

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Jayasri S.V