title: Warning: file_get_contents failed to open stream: No such file or directory?
body: <p>Here in this Iam uploading a file and then trying to send this file to another VM.</p>
  
  <p><strong>Code here</strong></p>
  
  <pre><code>// Debugging information -- No use in output    
  echo "&lt;/p&gt;";
  echo '&lt;pre&gt;';
  echo 'Here is some more debugging info:';
  print_r($_FILES);
  print "&lt;/pre&gt;";
  $file_name = $_FILES['userfile']['name'];
  echo $file_name;
  echo gettype($file_name);
  echo "&lt;br/&gt;";
  </code></pre>
  
  <p><strong>Output:</strong></p>
  
  <pre><code>Here is some more debugging info:Array
  (
      [userfile] =&gt; Array
          (
              [name] =&gt; 6274e8cb0358ef3e3906a91036bc84138a8fde606a6e926b9a580c79f9cfc489
              [type] =&gt; application/octet-stream
              [tmp_name] =&gt; /tmp/php3Yt3T5
              [error] =&gt; 0
              [size] =&gt; 3107800
          )
  
  )
  6274e8cb0358ef3e3906a91036bc84138a8fde606a6e926b9a580c79f9cfc489string
  </code></pre>
  
  <p>And it is printing the details correctly.But when i try to send this file to remote VM,it is creating errors.</p>
  
  <p>Code continuation</p>
  
  <pre><code>$localFile='/var/www/uploads/$file_name';
  echo $localFile;
  $remoteFile='/home/nsadmin/$file_name';
  $host='192.168.150.85';
  $port=22;
  $user='someusername';
  $pass='somepassword';
  
  $connection= ssh2_connect($host,$port);
  ssh2_auth_password($connection, $user, $pass);
  $sftp = ssh2_sftp($connection);
  
  $stream = fopen("ssh2.sftp://$sftp$remoteFile", 'w');
  $file = file_get_contents($localFile);
  fwrite($stream, $file);
  fclose($stream);
  </code></pre>
  
  <p><strong>Error Log:</strong></p>
  
  <pre><code> /var/www/uploads/$file_name Warning: file_get_contents(/var/www/uploads/$file_name): failed to open stream: No such file or directory in /var/www/MTP/upload.php on line 111 
  </code></pre>
  
  <p>Any suggestions on how to fix this error.</p>
  
  <p>P.S :</p>
  
  <p>I have used these for debugging at the start of php file</p>
  
  <pre><code>error_reporting(E_ALL);
  ini_set('display_errors',1);
  ini_set('log_errors',1);
  </code></pre>