title: PHP SMB File upload is successful but returns 500 Internal Server Error
body: <p>When I try to upload a file from a local folder on pc to the ftp server via SMB the file gets uploaded, however the server returns a 500 Internal Server Error with the following message:</p>
  <blockquote>
  <p>Warning: fopen(File.xls): failed to open stream: No such file or directory</p>
  </blockquote>
  <p>This is my function for the upload:</p>
  <pre><code>public function upload($fileToUpload, $targetPath = &quot;&quot;) {
      if (!empty($targetPath)) {
          if (substr($targetPath, -1, 1) != '/') {
              $targetPath .= &quot;/&quot;;
          }
      }
  
      $fileName = basename($fileToUpload);
      $this-&gt;srvShare-&gt;put($fileToUpload, $targetPath . $fileName);
  }
  </code></pre>
  <p><strong>$fileToUpload</strong> in this case is something like 'File.xls'.
  I already tried to give the function the whole path. But it still results in the same error.
  The upload does work.. the file is on the server but the code can't proceed since it's still resulting in a 500 Internal Server Error.</p>
  <p>This is the put() function from smb NativeShare:</p>
  <pre><code>/**
   * Upload a local file
   *
   * @param string $source local file
   * @param string $target remove file
   * @return bool
   *
   * @throws \Icewind\SMB\Exception\NotFoundException
   * @throws \Icewind\SMB\Exception\InvalidTypeException
   */
  public function put($source, $target) {
      $sourceHandle = fopen($source, 'rb');
      $targetUrl = $this-&gt;buildUrl($target);
      $targetHandle = $this-&gt;getState()-&gt;create($targetUrl);
      while ($data = fread($sourceHandle, NativeReadStream::CHUNK_SIZE)) {
          $this-&gt;getState()-&gt;write($targetHandle, $data, $targetUrl);
      }
      $this-&gt;getState()-&gt;close($targetHandle, $targetUrl);
      return true;
  }
  </code></pre>