![](/img/trans.png)
[英]Copy to clipboard without System.Windows.Forms.Clipboard?
[英]System.Windows.Forms.Clipboard works on desktop, but does not work on IIS
我有一个小模块,它正在剪贴板中寻找图像,如果存在,则将其显示在页面上。 这在我的桌面上效果很好,但在 IIS 上托管时永远不会进入 System.Windows.Forms.Clipboard.ContainsImage() 。 服务器端应用程序不能使用任何超出目的的概念,例如 Windows 剪贴板?
if (System.Windows.Forms.Clipboard.ContainsImage())
{
img = System.Windows.Forms.Clipboard.GetImage();
imgBytes = imageToByteArray(img);
string imgString = Convert.ToBase64String(imgBytes, 0, imgBytes.Length);
clipBoardImg.ImageUrl = "data:image/jpeg;base64," + imgString;
clipBoardImg.Visible = true;
}
如果您尝试在 IIS 上访问剪贴板,您将尝试在服务器上访问它,而不是在客户端上。 这肯定也会在服务器端失败,因为您的服务器进程中没有屏幕(您不是用户交互的)。
您应该做的是将此代码转换为客户端(例如javascript),这很难,因为您不能仅从客户端浏览器访问剪贴板。
我认为(几乎)不可能实现这一点。 使用input type=file
对您有帮助吗? 还是拖放表面? 这对我来说似乎是更好的选择。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.