2016-06-06 35 views
0

我的代碼如何保存圖像生成到百鳥

var featherEditor = new Aviary.Feather({ 
 
\t apiKey: 'your-client-id-here', 
 
\t theme: 'light', // Check out our new 'light' and 'dark' themes! 
 
\t tools: 'all', 
 
\t appendTo: '', 
 
\t onSave: function(imageID, newURL) { 
 
\t \t var img = document.getElementById(imageID); 
 
\t \t img.src = newURL; 
 
\t }, 
 
\t onError: function(errorObj) { 
 
\t \t alert(errorObj.message); 
 
\t } 
 
}); 
 
function launchEditor(id, src) { 
 
\t featherEditor.launch({ 
 
\t \t image: id, 
 
\t \t url: src 
 
\t }); 
 
\t 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>

我想保存圖像生成到百鳥:https://s3.amazonaws.com/feather-client-files-aviary-prod-us-east-1/2016-06-06/178ba6a3-0488-4b43-b4bc-133cf499c72c.jpg,並插入到MySQL。

如何取得網址並插入Mysql。

非常感謝!

回答

0

如果你仍然需要一個答案...

函數onSave將顯示編輯圖像的亞馬遜臨時URL。它在'newURL'變量中。

所以,你可以運行一個Ajax調用來將它發送到你的數據庫。

這部分代碼進入onSave函數。

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

Arceliver,非常感謝! –

+0

Arceliver,對不起沒有回覆你。 我沒有發佈您的帖子。 我對StackOverflow.com沒有太多的經驗 您的解決方案非常完美! 感謝回覆! –

相關問題