title: How to access a SMB server with PHP on Both Windows and Linux servers?
body: <p>I have a PHP script that generates an html file with data from a <code>POST</code> request (the file is a Thunderbird signature). I need to put this file in a folder on a SMB server.</p>
  
  <p>I have already made a working script in Java to create the folders and blank html files (so that Thunderbird doesn't freak out) on my SMB server, using the <a href="http://jcifs.samba.org/" rel="nofollow">JCIFS Library</a>. I log in to SMB with a static domain and a given username &amp; password. </p>
  
  <p>Also, the password contains special characters such as <code>@</code> and that could conflict with the basic <code>smb://WORKGROUP;user:password@host</code> <a href="http://wp.natsci.colostate.edu/cnsit/samba-smb-syntax/" rel="nofollow">syntax</a> I guess.</p>
  
  <p>Now, this works on Java just fine since I needed a cron, but now I have to do it on PHP since it has to be done right when the user validates the HTML form.</p>
  
  <p>The thing is that I don't know if the script will be put on a Windows Server or a Linux Server since we use both. I'm using Wamp (= Xampp) right now tho.</p>
  
  <p>I have found a few methods to do what I need, including <a href="https://github.com/icewind1991/SMB" rel="nofollow">this library</a> by Icewind as well as <a href="https://github.com/eduardok/libsmbclient-php" rel="nofollow">libsmbclient</a>. The thing is libsmbclient requires to be built on GNU/Linux. And the former library doesn't seem to support domain names as the Server class's constructor only takes these three arguments :</p>
  
  <pre><code>public function __construct($host, $user, $password) {
      $this-&gt;host = $host;
      $this-&gt;user = $user;
      $this-&gt;password = $password;
  }
  </code></pre>
  
  <p>So I don't really know what way (or library) to use to do the task I need as smb isn't supported by default in PHP. Also, the fact that I don't know if the script will be ran on Win or Nux is not helping.</p>
  
  <p>Perhaps there is a way to do this that I don't know of, and any help would be greatly appreciated.</p>
  
  <p>Thanks in advance,
  Coloco</p>