从剪贴板将图片上传到服务器 [英] upload picture to server from clipboard
问题描述
我一直在寻找解决方案很长时间,但找不到任何解决方案.是否可以将图片从剪贴板上传到服务器上的文件(通过按ctrl + v键)? 它可能适用于Chrome.
I was looking a long time for the solution, but I can not find any. Is there any possibility to upload picture from clipboard to file on server (by pressing ctrl+v) ? It could work for Chrome.
使用PHP,Javascript,jquery还是其他? chrome的某些外部扩展程序?
Use PHP, Javascript, jquery, or maybe sth else? Some external extension for chrome?
非常感谢.
推荐答案
您可以尝试:
https://github.com/layerssss/paste.js
或
粘贴事件和剪贴板API
On paste event and clipboard API
http://www.w3schools.com/jsref/event_onpaste.asp
https://www.w3.org/TR/clipboard-apis/
如何剪贴板功能中的粘贴图像可以在Gmail和Google Chrome 12+中使用吗?
使用javascript获取图像后,您可以使用AJAX将base64编码的图像发送到服务器.在服务器端,您可以对其进行解码并写入文件.
After you get image in javascript you can send base64 encoded image to server with AJAX. At server-side, you can decode it and write to a file.
注意:如果您在浏览器中复制图像(从其他选项卡或窗口),则此方法有效.当您从台式机复制图像时,该功能不起作用.
Note: This works if you copy image inside browser (from other tab or window). It doesn't work when you copy image from desktop.
这篇关于从剪贴板将图片上传到服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!