javascriptphpjquerymysqlaviary

How can save the image generate to Aviary


I have the code

var featherEditor = new Aviary.Feather({
	apiKey: 'your-client-id-here',
	theme: 'light', // Check out our new 'light' and 'dark' themes!
	tools: 'all',
	appendTo: '',
	onSave: function(imageID, newURL) {
		var img = document.getElementById(imageID);
		img.src = newURL;
	},
	onError: function(errorObj) {
		alert(errorObj.message);
	}
});
function launchEditor(id, src) {
	featherEditor.launch({
		image: id,
		url: src
	});
	return false;
}
<!-- Load Feather code -->
<script type="text/javascript" src="http://feather.aviary.com/imaging/v3/editor.js"></script>


<div id='injection_site'></div>

<img id='image1' src='http://images.aviary.com/imagesv5/feather_default.jpg'/>

<!-- Add an edit button, passing the HTML id of the image and the public URL of the image -->
<p><input type='image' src='http://images.aviary.com/images/edit-photo.png' value='Edit photo' onclick="return launchEditor('image1', 'http://images.aviary.com/imagesv5/feather_default.jpg');" /></p>

I want save the images generate to Aviary: https://s3.amazonaws.com/feather-client-files-aviary-prod-us-east-1/2016-06-06/178ba6a3-0488-4b43-b4bc-133cf499c72c.jpg and insert to MySQL.

How can take the url and insert to MysQL.

Thanks very much!


Solution

  • If you still need an answer...

    The function onSave will show the Amazon temporary URL for the edited image. It`s in the 'newURL' variable.

    So, you can just run an Ajax call to send this to your database.

    This part of code goes inside onSave function.

    $.ajax({
       url: <url_to_your_controller>,
                type:'post',
                data: {
                    image_url : newURL,
                },
                success:function() {
                    alert("Yeah! We did it!")
                }
            });