2

I am trying to send an image name using aviary and need the image name included. I have a hidden field in my form "img" Here is the code:

 <script type='text/javascript'>
 var featherEditor = new Aviary.Feather({
 apiKey: 'yogbsxxxxxxxx4',
 apiVersion: 3,

 theme: 'dark', // Check out our new 'light' and 'dark' themes!
 tools: 'enhance,crop,orientation,brightness,sharpness,redeye,resize,text',
 appendTo: '',
 onSave: function(imageID, newURL) {
 var img = document.getElementById(imageID);
 img.src = newURL;

 },
 onError: function(errorObj) {
 alert(errorObj.message);
 },
 postUrl: 'http://xxxxx/~gsidev/gallery/post.php',
 postData : document.getElementById(img),// this is the field I need and does not work?

 });
 function launchEditor(id, src) {
 featherEditor.launch({
 image: id,
 url: src
  });
 return false;
 }
 </script>

Thanks for any guidance. The support for php implementation is terrible on Aviary...

1 Answers1

1

Figured it out! I added a new variable and passed it. This will send the file name in php and overwrite the existing file providing your post url file is inside the same folder as the your image you called for the editor.

  function launchEditor(id, src, img) {
  featherEditor.launch({
  image: id,
  url: src,
 postData : img
   });
  return false;
  }
  </script>

Now on the save page :

     $image_data = file_get_contents($_REQUEST['url']);

    file_put_contents(($_REQUEST['postData']),$image_data);

 ?>

And change the link or button code to match

 <!-- Add an edit button, passing the HTML id of the image
     and the public URL to the image -->
  <a href="#" onclick="return launchEditor('editableimage1',"imagename.jpg" 
     'http://example.com/public/images/goat.jpg');">Edit!</a>