Question: Essentially this code searches through a string, finds and replaces according to the each of these regex patterns before spitting the updated variable back. 

I'm having difficulty translating it from PHP code to Javascript: 

in PHP I have achieved it as such: 

```
$dataPreg = array(
'/(.*)\s§/' => '$1 <span class="suppSmall">quasi</span>',
'/(\bor|and\b)/'=>'<span class="orChar">$1</span>',
'/\:(\s*see[\:]?)/'=>'<span class="orChar"> $1: </span>'
);

$root = preg_replace(array_keys($dataPreg),array_values($dataPreg),$root);

return $root;

```

in Javascript I attempted to port it as such: 

```
var dataPreg = {
'/(.*)\s§/':'$1 <span class="suppSmall">quasi</span>',
'/(\bor|and\b)/':'<span class="orChar">$1</span>',
'/\:(\s*see[\:]?)/':'<span class="orChar"> $1: </span>'
};

for (var val in dataPreg)
$string = $string.replace(new RegExp(val, "g"), dataPreg[val]);
return $string;

```

Needless to say, its not working in Javascript and I can't figure out why. It doesn't trigger any JS errors, it simply returns the string back..unchanged.

Answer: 
I had this problem myself and it seems like the reason is that a non base64-encoded image may contain bytes that terminate a post request etc. so the request will be invalid.

Another reason may be your webprovider. A freehoster I had tried didn't work, but when I moved to another hoster without changing *a single line* everything worked perfectly.

I recommend you to use RestSharp:

```
RestRequest request = new RestRequest("url", Method.POST);
request.AddParameter("image",  Convert.ToBase64String(imagestream.ToArray());
RestClient client = new RestClient();
client.ExecuteAsync(request, (response) =>
{
    //Do something with the response
}

```
Try to convert your image with this:

```
  public byte[] FileToByteArray(string fileName)
  {

       byte[] buff = null;

       if (fileName != null && fileName != "" && File.Exists(fileName))

       {

          buff = File.ReadAllBytes(fileName);

       }
        return buff;
    }

```

In my database the column for the picture is type image.I hade the same problem and i fixed it with this.