title: json_encode formatting - froala
body: <p>I'm using Froalo for text editing, but I'm having difficulties getting the image upload to function correctly. Testing on localhost. </p>
  
  <p>The documentation says that </p>
  
  <pre><code>imageUploadURL: '/upload_image.php',
  </code></pre>
  
  <p>should return a json string formated like this :</p>
  
  <pre><code>{ link: 'path/to/image.jpg' }
  </code></pre>
  
  <p>my javascript looks this this :</p>
  
  <pre><code>$(function() {
      $('#edit').froalaEditor({
          language:'fr',
          imageUploadURL: 'upload.php'
      })
  });
  </code></pre>
  
  <p>my upload.php looks like this :</p>
  
  <pre><code>var_dump($_FILES);
  require('clean.php'); // removes french special characters
  $image = clean($_FILES['file']['name']);
  $uploaddir = '../photos/';
  $uploadfile = $uploaddir . basename($image);
  $retour = ['link'=&gt; $uploadfile];
  $b = json_encode($retour);
  $array_final = preg_replace('/"([a-zA-Z]+[a-zA-Z0-9_]*)":/','$1:',$b);
  if( move_uploaded_file($_FILES['file']['tmp_name'],$uploadfile)) {
      echo stripslashes($array_final);
  } else {
      echo "Lo kol kakh tov...";
  }
  </code></pre>
  
  <p>When I run this from the text editor through froalaEditor, </p>
  
  <ul>
  <li>the file gets uploaded to the server,  </li>
  <li><p>firebug says that upload.php
  answers the array $_FILES and :</p>
  
  <p>{link:"../photos/sama1.jpg"}</p></li>
  </ul>
  
  <p>That all seems good, but froala answers that "something" went wrong and the images doesn't appear in the editor. </p>
  
  <p>Could it be because of the double quotes around the image url? </p>