我正在尝试使用鸟舍发送图像名称,需要包含图像名称。 我的表单"img"中有一个隐藏字段 这是代码:
<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>
感谢您的任何指导。 在 Aviary 上对 php 实现的支持很糟糕......
想通了! 我添加了一个新变量并传递了它。 这将以 php 格式发送文件名并覆盖现有文件,前提是您的 post url 文件与您为编辑器调用的图像位于同一文件夹中。
function launchEditor(id, src, img) {
featherEditor.launch({
image: id,
url: src,
postData : img
});
return false;
}
</script>
现在在保存页面上:
$image_data = file_get_contents($_REQUEST['url']);
file_put_contents(($_REQUEST['postData']),$image_data);
?>
并更改链接或按钮代码以匹配
<!-- 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>