title: Froala - image upload JSON response
body: <p>I am using <a href="http://editor.froala.com/" rel="nofollow">Froala editor</a> for my website. This editor have built in image upload function - image upload is working fine, but I am having trouble with response.</p>
  
  <p>This is from the documentation:</p>
  
  <pre><code>The server processes the HTTP request.
  The server has to process the upload request, save the image and return a hashmap containing a link to the uploaded image. The returned hashmap needs to look like: { link: 'path_to_uploaded_file/file.png' }
  </code></pre>
  
  <p>This is my function for returning link:</p>
  
  <pre><code>public function froala_upload()
      {
          header('Content-type: application/json');
          $folder = 'public/img/media';
          $slika = $this-&gt;site-&gt;single_upload($folder, 'jpg|jpeg|png|bmp|JPG|JPEG|PNG|BMP');
          $link = array("link" =&gt; $slika);
  
          echo json_encode($link);
      }
  </code></pre>
  
  <p>This is JS code:</p>
  
  <pre><code>$('textarea').editable({
    inlineMode: false,
    imageUploadParam: "userfile",
    imageUploadURL: "&lt;?php echo base_url() ?&gt;admin/froala_upload",
    // Set the image error callback.
    imageErrorCallback: function (data) {
        // Bad link.
        if (data.errorCode == 1) {
          console.log(data);
        }
  
        // No link in upload response.
        else if (data.errorCode == 2) {
          console.log(data);
        }
  
        // Error during file upload.
        else if (data.errorCode == 3) {
          console.log(data);
        }
    }
  });
  </code></pre>
  
  <p>When I upload image I get following error:</p>
  
  <pre><code>Object { errorCode=1, errorStatus="Bad link."}
  </code></pre>
  
  <p>And this is response that I get:</p>
  
  <pre><code>{"link":"7d59d61.jpg"}
  </code></pre>
  
  <p>What seem to be a problem?</p>
  
  <p><a href="http://editor.froala.com/docs/image-upload" rel="nofollow">Froala image upload documentation</a></p>