File streaming in PHP - How to replicate this C#.net code in PHP?
<p>I'm writing an interface to a web service where we need to upload configuration files.  The documentation only provides a sample in C#.net which I am not familiar with.  I'm trying to implement this in PHP.</p>

<p>Can someone familiar with both languages point me in the right direction?  I can figure out all the basics, but I'm trying to figure out suitable PHP replacements for the FileStream, ReadBytes, and UploadDataFile functions.  I believe that the RecService object contains the URL for the web service.  Thanks for your help!</p>

<pre><code>    private void UploadFiles() {
    clientAlias = “&lt;yourClientAlias&gt;”; 
    string filePath = “&lt;pathToYourDataFiles&gt;”; 
    string[] fileList = {"Config.txt", "ProductDetails.txt", "BrandNames.txt", "CategoryNames.txt", "ProductsSoldOut.txt", "Sales.txt"}; 
    RecommendClient RecService = new RecommendClient();
    for (int i = 0; i &lt; fileList.Length; i++) {
        bool lastFile = (i == fileList.Length ‐ 1); //start generator after last file 
        try {
            string fileName = filePath + fileList[i]; 
            if (!File.Exists(fileName))
                continue;   // file not found
            }
            // set up a file stream and binary reader for the selected file and convert to byte array 
            FileStream fStream = new FileStream(fileName, FileMode.Open, FileAccess.Read); BinaryReader br = new BinaryReader(fStream);
            byte[] data = br.ReadBytes((int)numBytes); br.Close();
            // pass byte array to the web service
            string result = RecService.UploadDataFile(clientAlias, fileList[i], data, lastFile); fStream.Close(); fStream.Dispose();
        } catch (Exception ex) {
            // log an error message
        }
    }
}
</code></pre>
